Emailing Reports to Users on a Business Event

OTM can automatically generate a report and email it as an attachment when a business event occurs. The example below shows how to send a custom report to the user who created a purchase order when a shipment tender is accepted.

Step 1 — Create a Report Set:

Business Process Automation > Reporting > Report Manager > Report Set Manager

Create a Report Set and include your report. You may add multiple reports to the Report Set as required.

Step 2 — Create a SHIPMENT agent with a PRINT DOCUMENT action:

Create a SHIPMENT agent that listens to the SHIPMENT - STATUS CHANGED event with the restriction SECURE RESOURCES_ACCEPTED. Add the following standard action to the agent:

PRINT DOCUMENT: Specify the name of the Report Set from Step 1 and the output format (e.g. PDF). When a tender is accepted, this action generates the report and OTM raises a standard REPORT-READY event for the generated report.

Step 3 — Create a REPORT agent that listens to the REPORT-READY event:

Create a REPORT agent that listens to the REPORT-READY event with an event restriction that filters on the Report Set name from Step 1. Add the following two actions to this agent:

Action 1 — ASSIGN VARIABLE to fetch the PO creator:

Use the ASSIGN VARIABLE action with the following SQL to fetch the user who created the purchase order:

SELECT MAX(ob.insert_user)
FROM   report_log_parameter rlp,
       view_shipment_order_release vsor,
       order_release orl,
       ob_order_base ob
WHERE  file_name = $gid
AND    parameter_name = 'P_SHIPMENT_ID'
AND    parameter_value = vsor.shipment_gid
AND    vsor.order_release_gid = orl.order_release_gid
AND    orl.order_base_gid = ob.order_base_gid
Note: The REPORT_LOG_PARAMETER table stores the input parameter values used for each report run. This query fetches the Shipment ID parameter value and joins to the related PO to identify the creator. A separate report definition for email purposes may be required — report definitions with multiple parameters beyond Shipment ID may not work reliably in this context.

Action 2 — NOTIFY CONTACT:

Use the NOTIFY CONTACT action with the following settings:

Contact: Set to the variable returned by Action 1. Create Contact records under Business Process Automation > Communication Management > Contacts with Contact ID matching the User ID for each user who should receive emails. Ensure the Notification On flag is checked on each Contact record.
Communication Method: EMAIL
Subject: Use a dynamic subject with variables, for example: Report - ShpRef#: $SHP_REF; SID=$GID
Stylesheet Profile: Create a Stylesheet Profile under Business Process Automation > Power Data > Event Management > Stylesheet Profiles with the following settings:
  • Template Name: workflow/DefaultReportEventHtml.xsl (Standard)
  • Format: text/html
  • Subject Property Key: {2} — this ensures the email subject uses the value defined in the NOTIFY CONTACT action
  • Message Direction: OUTBOUND
  • Type: XSL
  • Attachments: EMBED

Questions & Discussion

Have a question about this topic? Post it below using your GitHub account. Comments are visible to everyone and help other OTM consultants with the same question.