system.report.executeAndDistribute

Description

Executes and distributes a report.

The action parameter supports the following keys as strings:

  • email

  • print

  • save

  • ftp

The action settings parameter supports an optional dictionary of settings particular to the action. Missing values will use the default value for that action.

  • email

    • Setting Keys: "smtpServerName", "from", "subject", "body", "attachmentName", "retries", "fileType", "to", "cc", "bcc", "useRoles", "roles", "userSource".

    • Note: To, cc, and bcc 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. If useRoles is true but no roles are listed, all user email addresses in userSource will be in the to field. fileType can be pdf, html, csv, rtf, jpeg, png, or xml and is not case-sensitive. If omitted, fileType defaults to pdf.

  • print

    • Setting Keys: "primaryPrinterName", "backupPrinterName", "copies", "printBothSides", "collate", "useRaster", "rasterDPI", "useAutoLandscape", "pageOrientation".

    • Note: 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".

    • Note: 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".

    • Note: Server and fileName are required. If omitted, fileType defaults to pdf, port defaults to 21, and useSSL defaults to false.


Syntax

This function accepts keyword arguments.

system.report.executeAndDistribute(path, project, [parameters], action, [actionSettings])

  • Parameters

String path - The path to the existing report.

String project - The name of the project where the report is located. Optional in client scope.

PyDictionary parameters - A optional dictionary of parameter overrides, in the form name:value.

String action - The name of the distribution action to use.

PyDictionary actionSettings - An optional dictionary of settings particular to the action. Missing values will use the default value for that action.

  • Returns

None

  • Throws

IllegalArgumentException - Thrown 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.

  • Scope

All

Code Examples
Code Snippet
#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"})
Code Snippet
#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"})
Code Snippet
#Executes and distributes the report to an ftp server
settings = {"server":"10.20.1.80", "port":22, "username":"Ignition", "password":"Secret", "useSSL": False, "path":"C:\\FTP", "fileName":"Ignition Report", and "format":"pdf"}
system.report.executeAndDistribute(path="My Report Path", project="My Project", action= "ftp", actionSettings = settings)
Code Snippet
#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)