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:
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:
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_gidAction 2 — NOTIFY CONTACT:
Use the NOTIFY CONTACT action 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