When trying to use system.report.executeAndDistribute
to send the report via email I noticed that the report I try to send is for example filtered to just 5 pages but the report that I receive via email is not filtered at all.
Below is the code, is there something wrong or missing that I need to add?
system.report.executeAndDistribute(path = event.source.parent.getReport, action = "email", actionSettings = {"to":recipients, "smtpServerName":mailServer, "from":fromAdd, "subject":subject, "attachmentName":subject, "body":body})
lrose
October 21, 2022, 4:37pm
2
You are not providing any parameter overrides, so the report is executed using the default parameter values.
system.report.executeAndDistribute(path = 'path',parameters = {'your parameter':'your paremter value'}, action = 'action')
1 Like
is the "actionSettings" that are specified different from the parameter override?
lrose
October 21, 2022, 5:01pm
4
Yes, the actionSettings
are specific to the indicated action
that the function should take once the report is executed. The parameters give the report values to use when generated.
Changed it to this but I'm not receiving the email and seeing this error on console
system.report.executeAndDistribute(path = event.source.parent.getReport, parameters = {"to":recipients, "smtpServerName":mailServer, "from":fromAdd, "subject":subject, "attachmentName":subject, "body":body}, action = "email")
"SMTP server name in Email does not exist."
But it does exist, and I've tested that it's working
lrose
October 21, 2022, 5:49pm
6
You have to provide the parameters for the report, and the settings for the action. They are not the same thing.
For example, lets say that your report has a startDate
and an endDate
parameter. By default endDate = now()
and startDate = addHours(now(),-24)
If you were to call
actionSettings = {'to':recipients,'smtpServerName':mailServer,'from':fromAdd,'subject':subject,'attachmentName':subject,'body':body}
action = 'email'
system.report.executeAndDistribute(path=event.source.parent.getReport,action=action,actionSettings = actionSettings)
You would get a report emailed that is executed for 24 hours of data, if instead you wanted only 5 hours of data you would need to call it like this:
actionSettings = {'to':recipients,'smtpServerName':mailServer,'from':fromAdd,'subject':subject,'attachmentName':subject,'body':body}
action = 'email'
parameters = {'startDate':system.date.addHours(system.date.now(),-5)}
system.report.executeAndDistribute(path=event.source.parent.getReport,parameters = parameters,action=action,actionSettings = actionSettings)
1 Like
ohhh im so dumb, thank you for clarifying! its working now!