--- title: "system.report.executeAndDistribute" description: "Executes and distributes a report." --- # system.report.executeAndDistribute > Executes and distributes a report. This function is used in **Python Scripting**. ## Description Executes and distributes a report. Similar to [scheduling a report to execute](ignition-modules\reporting\report-schedules\report-schedules.md), except a schedule is not required to utilize this function. This is a great way to distribute the report on demand from a Client. Throws an IllegalArgumentException when any of the following occurs: If the file type is not recognized, path does not exist, project does not exist, or a key is not valid. :::note The function system.report.executeAndDistribute() does not run on its own thread and can get blocked. For example, if a printer is backed up and it takes a while to finish the request made by this function, the script will block the execution of other things on that thread until it finishes. Be sure to keep this in mind when using it in a script. ::: ## Client Permission Restrictions This scripting function has no [Client Permission](../../../ignition-modules/vision/vision-project-properties/vision-project-properties.md#vision-permissions-properties) restrictions. ## Syntax :::tip This function accepts [keyword arguments](platform\scripting\python-scripting\user-defined-functions.md#keyword-arguments). ::: `system.report.executeAndDistribute(path, project, [parameters], action, [actionSettings])` ### Parameters Type | Parameter | Description ------- | ------- | ------ String | `path` | The path to the existing report. String | `project` | The name of the project where the report is located. Optional in client scope. Dictionary[String, Integer] | `parameters` | A dictionary of parameter overrides, in the form name:value pairs. [optional] String | `action` | The name of the distribution action to use. The action parameter supports the following keys as strings:emailprintsaveftp Dictionary[List, Any] | `actionSettings` | A dictionary of settings particular to the action. Missing values will use the default value for that action. [optional] ### Returns Nothing ### Scope Gateway, Vision Client, Perspective Session ## Values for actionSettings The action settings parameter supports an optional dictionary of settings particular to the action. Missing values will use the default value for that action. :::note The email action now has the ability to add emails to the reply to field of the email. The replyTo, replyToRoles, and replyToUserSource keys have been added to the possible dictionary options. ::: - email - Setting Keys: "smtpServerName", "from", "subject", "body", "attachmentName", "retries", "fileType", "to", "cc", "bcc", "replyTo", "useRoles", "roles", "userSource", "replyToRoles", "replyToUserSource". - `To`, `cc`, `bcc`, and `replyTo` must be Python lists. If useRoles is True, `to`, `cc` and `bcc` will be ignored and all email addresses for all users matching `roles` in `userSource` (which defaults to the project's current user source) will be in the to field. Similarly, all users matching the `replyToRoles` in `replyToUserSource` will be in the `reply` to field of the email. If `useRoles` is true but no `roles` are listed, all user email addresses in `userSource` will be in the to field. If omitted, `fileType` defaults to pdf. In addition, smtpServerName is the name of the [SMTP Profile](../../../platform/gateway/config/email-settings/email-settings.md) on the Gateway. - print - Setting Keys: "primaryPrinterName", "backupPrinterName", "copies", "printBothSides", "collate", "useRaster", "rasterDPI", "useAutoLandscape", "pageOrientation". - `primaryPrinterName` defaults to the default printer. `backupPrinterName` defaults to "none", but can also have the special value of "default". `printBothSides`, `collate`, and `useRaster` are booleans which default to false. `rasterDPI` is only used if `useRaster` is true. `useAutoLandscape` defaults to true. If `useAutoLandscape` is false, `pageOrientation`, which can have values of "portrait" or "landscape" (default is "portrait"), is used. - save - Setting Keys: "path", "fileName" and "format". - Since the script is sent to the gateway for execution, path and fileName must be relative to the Gateway. - ftp - Setting Keys: "server", "port", "username", "password", "useSSL", "path", "fileName", and "format". - Server and fileName are required. If omitted, fileType defaults to pdf, port defaults to 21, and useSSL defaults to false. ## Values for the fileType Parameter Acceptable values are: - pdf (recommended) - html - csv - rtf - jpeg - png - xml - xls - xlsx :::note xls and xlsx Formats The xls and xlsx format options may return less than pixel perfect results. This is due to how many spreadsheet programs interpret the resulting file. As a result, the pdf format is recommended in most cases. ::: ## Code Examples ```python title="Code Snippet - Emailing a Report"" # Executes and distributes the report to an email address. system.report.executeAndDistribute(path="My Report Path", project="My Project", action= "email", actionSettings = {"to":["plantmanager@myplant.com"], "smtpServerName":"myplantMailServer", "from":"reporting@myplant.com", "subject":"Production Report"}) ``` ```python title="Code Snippet - Emailing a Report" # Executes and distributes the report to all users in the default user source who are Supervisors or Managers. system.report.executeAndDistribute(path="My Report Path", project="My Project", action= "email", actionSettings = {"useRoles":True, "roles":["Supervisor", "Manager"], "smtpServerName":"myplantMailServer", "from":"reporting@myplant.com", "subject":"Production Report"}) ``` ```python title="Code Snippet - Emailing a Report" # Executes and distributes the report to all users in the user source specified which has no roles defined. system.report.executeAndDistribute(path="My Report Path", project="My Project", action= "email", actionSettings = {"userSource":"TestUsers","useRoles":True, "roles":[], "smtpServerName":"papercut", "from":"test@test.com", "subject":"Test Report"}) ``` ```python title="Code Snippet - Sending Report to FTP Server" # Executes and distributes the report to an ftp server with parameter values passed into the report reportParameters = {"StartDate":system.date.addHours(system.date.now(), -12), "EndDate":system.date.now()} settings = {"server":"10.20.1.80", "port":22, "username":"Ignition", "password":"Secret", "useSSL": False, "path":"C:\\FTP", "fileName":"Ignition Report", "format":"pdf"} system.report.executeAndDistribute(path="My Report Path", project="My Project", parameters=reportParameters, action= "ftp", actionSettings = settings) ``` ```python title="Code Snippet - Saving Report" # Executes and distributes the report to save a PDF settings = {"path":"C:\\Ignition Reports", "fileName":"Report.pdf", "format":"pdf"} system.report.executeAndDistribute(path="My Report Path", project="My Project", action="save", actionSettings=settings) ```