Generating Email Attachments for Fixed Link Reports

Scenario: You want to generate a fixed link report and email it as an attachment to an already configured list of recipients in the Recipients Editor tab of the Notification application at a scheduled time. As a result, the report will be emailed in the specified format to the specific recipients from the Recipients Editor tab.

 

Reference: For background information, see the reference section.

 

Workflow diagram:

 

The workflow offers three options to manually send or schedule times to automatically send the email:

  • Option 1 – Use the Application View to manually send the email from the fixed link itself.
  • Option 2 – Use the Reaction Editor to program a reaction that will schedule the email distribution daily, weekly, or monthly.
  • Option 3 – Use the Scripting Editor to write a script that will schedule the email distribution.

 

Prerequisites:

  • You have configured a Web Rule and created a fixed link.
  • You have configured SMTP Email server using Notification extension.
  • You have created recipients in the Recipients Editor tab of the Notification application. See Create Recipient Users or Recipient Devices in Creating and Configuring Recipients.

 

Steps:

1 - Set User Credentials for Executing a Fixed Link
  • System Manager is in Operating mode.
  • You created fixed links for an external web application.
  • You want to execute (automatically or manually) and download an external web application fixed link report. To do this you must first set the relevant fixed link to be executed with user credentials.
  1. In System Browser, select Application View.
  1. Select Applications > Links > [fixed link].
  • The Application Viewer tab displays.
  1. Click Set Credentials .
  1. In the Web Viewer dialog box, enter a user name and password.
    NOTE: You must choose a user with the appropriate privileges. Make sure you create a password that will not expire in the near future because once a user password expires, reports will not execute correctly.
  1. In the Extended Operation tab, specify the parameter values for the link.
  • The user credentials are set for the link and parameter values specified.
    NOTE: In the Operating mode, you can run a report in the Application Viewer by selecting the link from Applications > Links, if the value of the P2 parameter is set to HTML. However, if the value of the P2 parameter is set to any other value (for example, XLSX, DOCX, PDF), then you cannot run the report in the Application Viewer. In this case, you can run the report by clicking Execute in the Extended Operation pane, and specifying the required parameter values.

 

2 - Configure Email Settings for a Fixed Link Report

You want to create an email template for a fixed link.

  • You have created a Web Rule and a fixed link for any Advanced, Energy, or Pharma reports.
  • You have set the User Credentials.
  • You have created recipients in the Recipients Editor tab of the Notification application. See Create Recipient Users or Recipient Devices in Creating and Configuring Recipients.
  • System Manager is in Operating mode.
  1. In System Browser, select Application View.
  1. Select Applications > Links > [fixed link] for which you want to configure the email settings.
  1. From the Application Viewer toolbar, click Email Settings .
  • The Email Settings dialog box displays.
  1. To add the recipients’ names, in the Address Book section, do one of the following:
  • In the drop-down list, select People or Group. A list of individuals or groups displays.
  • Type the name or the group you want to add. The specified individual or group displays.
    NOTE: When you press ENTER, the query is temporarily saved in the drop-down list.
  1. From the list of people or groups, use the > and < arrows to add or remove names or groups to and from the Recipients section.
    NOTE: An individual recipient may have more than one email address associated with their entry in the Notification application’s Recipients Editor. When you add an individual, the first three configured email settings associated with the user are added and display in the Recipients section. The report is sent to all three associated addresses.
  1. In the Subject field, type a subject for the email, or, leave the default text.
  1. In the Body field, type a message you want to appear in the body of the email, or, leave the default text.
  1. Click Save .

 

3 - (Option 1) Manually Execute and Email a Fixed Link Report
  • You have set the user’s execution credentials for an external web application fixed link and now you want to generate a report from that fixed link in a specific format and download it onto the local machine.
  1. In System Browser, select Application View.
  1. Select Applications > Links > [links folder] > [link].
  1. In the Operation tab, select the Application Name property, and do one of the following:
  • To send the report as an email, and optionally download the report, click Email.
  • To download the report only, click Execute.
  • The configuration fields display.
  1. If you clicked Email, do the following:
    a. From the Output For drop-down list, select the format in which you want to save the downloaded report (PDF, XLSX, or DOCX).
    NOTE: The P2 Value and Output values must match. See Modifying the Settings of a Web Application Fixed Link.
    b. (Optional) To also download the report, in the File Name field, enter the name of the file. The following special characters are not allowed in the file name in Windows: / \ ? : * “ < >
    c.
    (Optional) To also download the report, in the File Path field, enter the path of the destination folder on the local machine.
    d. From the Section drop-down list, select Save.
    NOTE: The sections are specified in the XML file of the corresponding web links library.
    e. To generate a report file with a unique name, specify the timestamp format in the Time Stamp field.
    f. Click Send.
  • The report is sent to the established recipients as configured in the Email Settings for the fixed link. If you have included the File Name and File Path information, the report file is available in the specified directory. Its name is a combination of the File Path and Time Stamp settings.
  1. If you clicked Execute, complete all the following fields to download a report file:
    a. From the Output For drop-down list, select the format in which you want to save the downloaded report (HTML, PDF, rptdesign, or DOCX).
    NOTE: P2 Value and Output for values must match. See Modifying the Settings of a Web Application Fixed Link.
    b. In the File Name field, enter the name of the file. The following special characters are not allowed in the file name in Windows: / \ ? : * “ < >
    c.
    In the File Path field, enter the path of the destination folder on the local machine.
    d. From the Section drop-down list, select Save.
    NOTE: The sections are specified in the XML file of the corresponding web links library.
    e. To generate a report file with a unique name, specify the time stamp format in the Time Stamp field.
    f. Click Send.
  • The report file is available in the specified directory. Its name is composed by the combination of the File Path and Time Stamp settings.

 

4 - (Option 2) Create a Program to Email a Fixed Link Email Attachment

You will configure a reaction that will execute that report during nighttime hours and send it at a scheduled time to a list of recipients.

  • System Manager is in Engineering mode.
  1. In System Browser, select Application View.
  1. Select Applications > Logics > Reactions.
  1. Click the Reaction Editor tab.
  1. In System Browser, select the Manual navigation check box.
  1. In the Output expander, open the Action expander, and then select Applications > Links > [fixed link].
  1. Drag the external web application fixed link into the Scope/Target fields of the Action expander.
  1. In the Action expander, select the newly-created instruction row and set the following values to send email:
  • Property = Application Name [AppName]
  • Command = Send Email. (SendEmailExecute)
  • FileExtension = PDF[0], Docx [1], XLXS [2]
  • FileName = Enter the desired values—for example, Report304
  • FilePath = Enter the desired value. The path should generally include \\ to follow scripting standards—for example, [Installation Drive]:\[Installation Folder]\[Project Name]\data\Reporting\Reports\
  • Section = Viewer [0], Save Document [1], Caching [2]
  1. To download the output file, in the Action expander, select the newly-created instruction row and set the following values to send email:
  • Property = Application Name [AppName]
  • Command = Execute. (WebAppExecute)
  • FileExtension = PDF[0], Docx [1], XLXS [2]
  • FileName = Enter the desired values—for example, Report304
  • FilePath = Enter the desired value. The path should generally include \\ to follow scripting standards—for example, [Installation Drive]:\[Installation Folder]\[Project Name]\data\Reporting\Reports\
  • Section = Viewer [0], Save Document [1], Caching [2]
  1. In the Triggers expander, open the Time and Organization Mode expander, and click the first row.
    a. In the Time column, clear the Begin of day and End of day check boxes, and select the Set End Time check box.
    b. In the Set Start Time field, enter 12:00:00 AM.
    c. In the Set End Time field, enter 07:00:00 AM.
  • The Time field is set to From 12:00 to 7:00 AM.
  1. In the Effective Days field, from the drop-down list, select Recurrence = Occurs all days.
  • The Effective Days field, is set to Occurs all days.
  1. In the General Settings expander, enter text in the Notes field, for example, EmailWebAppReportatNight.
  1. Click Save As .
  1. In the Save Object As dialog box, select the main Reactions folder or any subfolder under it as the destination where you want to save this reaction.
    a. In the Name field, enter EmailWebAppReportatNight, as you did above.
    b. Click OK.

 

5 - (Option 3) Create a Script to Email a Fixed Link Attachment

You want to configure a script that will carry out the Execute command on the Application Name: Advanced Reports property based on the provided parameters settings. The report output will then be emailed in the specified format to the specific recipients from the Address Book.

  • System Manager is in Engineering mode.
  • You have set the user’s execution credentials for an external web application fixed link. See Related Topics below for more information.
  1. In System Browser, select Application View.
  1. Select Applications > Logics > Scripts.
  1. Click the Script Editor tab.
  1. Click Save As .
  1. In the Save Object As dialog box, select the main Scripts folder or any subfolder under it as the destination for saving the new script.
    a. In the Name field, enter a name, for example, WebAppReportScript.
    b. Click OK.
  • The new script is added to System Browser and automatically selected. The Script Editor tab displays its code.
  1. In the Editor expander, enter the script code to execute a command. For Script examples, see Related Topics below.
  1. Click Save .
  • When you start the script, the report is executed as configured.

 

Related Topics

For Script examples, in the Help, navigate to Engineering Reference > Logics > Scripts > Scripts Syntax Reference > Script Code Samples, and see the following topics:

  • Send Email Command for a Scheduled External Application Report.
  • Download Output File for a Scheduled External Application Report.