Sent report is not filtered

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})

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?

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

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! :star_struck: