In day-to-day processes, effective email notification is a critical component of business success. Many clients are recognizing the importance of integrating email functionality into their integration. This adjustment inside integration not only enhances email notification but also offers greater visibility into key processes.
This involves tracking key records entering the integration, capturing both successful and failed entries, along with essential details such as basic map information, run date/time, and count, and ensuring a more user-friendly email format.
Here’s a solution for implementing it with global variables, along with strategies to effectively manage them according to your requirements.
If you’d rather watch a video on how this is completed, click here.

Steps:
- Include the following three variables in the “Global Variables” session >> Add
GBL_EMAIL_ERROR_LOG
GBL_EMAIL_SUCCESS_LOG
GBL_EMAIL_FAILURE_LOG

- Add a script to reset the variables – set the default value as a blank string.
Go to Tasks Tab >> Integration Pre Tasks >> Tasks that run before the integration >> New Task >> Run Script

Give Name >> RESET_VAR >> Add the below script and click on “Validate”
GBL_EMAIL_ERROR_LOG = ""; GBL_EMAIL_SUCCESS_LOG = ""; GBL_EMAIL_FAILURE_LOG = ""; return true;
GBL_EMAIL_ERROR_LOG = "" GBL_EMAIL_SUCCESS_LOG = "" GBL_EMAIL_FAILURE_LOG = "" return true

- This is about capturing the failure message to the failure global variable “GBL_EMAIL_FAILURE_LOG”
Add Task >> Document Tasks >> Task that run if the document fails >> New Task >> Run Script

Give Name >> CAPTURE_FAILURE_MSG >> Add the below script and click on “Validate”.
GBL_EMAIL_FAILURE_LOG = GBL_EMAIL_FAILURE_LOG +
Environment.NewLine + "Customer PO Number: " + _CUSTOMERPONUMER +
Environment.NewLine + "Customer Number: " + _CUSTOMERNUMBER +
Environment.NewLine + "Document Date: " + _DOCUMENTDATE +
Environment.NewLine + "Freight: " + _FREIGHT +
Environment.NewLine + "Order Number: " + GlobalRollingColumn +
Environment.NewLine + "------------------------------------------" ;
return true;
GBL_EMAIL_FAILURE_LOG = GBL_EMAIL_FAILURE_LOG & Environment.NewLine & "Customer PO Number: " & _CUSTOMERPONUMER & Environment.NewLine & "Customer Number: " & _CUSTOMERNUMBER & Environment.NewLine & "Document Date: " & _DOCUMENTDATE & Environment.NewLine & "Freight: " & _FREIGHT & Environment.NewLine & "Order Number: " & GlobalRollingColumn & Environment.NewLine & "------------------------------------------" return true

- This is about capturing the current error message to the error global variable “GBL_EMAIL_ERROR_LOG”.
Add Task >> Document Tasks >> Task that run if the document fails >> New Task >> Run Script

Give Name >> CAPTURE_ERROR_LOG >> Add the below script and click on “Validate”.
Note – GlobalLastError indicates the current error message.
GBL_EMAIL_ERROR_LOG = GBL_EMAIL_ERROR_LOG +
Environment.NewLine + "Order Number: " + GlobalRollingColumn +
Environment.NewLine + "Error: " + fn.REPLACE(GlobalLastError,"'"," ") +
Environment.NewLine + "------------------------------------------" ;
return true;
GBL_EMAIL_ERROR_LOG = GBL_EMAIL_ERROR_LOG & Environment.NewLine & "Order Number: " & GlobalRollingColumn & Environment.NewLine & "Error: " & fn.REPLACE(GlobalLastError,"'"," ") & Environment.NewLine & "------------------------------------------" return true

- This is about capturing the success message to the success global variable “GBL_EMAIL_SUCCESS_LOG”
Add Task >> Document Tasks >> Task that run if the document succeeds >> New Task >> Run Script

Give Name >> CAPTURE_SUCCESS_MSG >> Add the below script and click on “Validate”
GBL_EMAIL_SUCCESS_LOG = GBL_EMAIL_SUCCESS_LOG +
Environment.NewLine + "Customer PO Number: " + _CUSTOMERPONUMER +
Environment.NewLine + "Customer Number: " + _CUSTOMERNUMBER +
Environment.NewLine + "Document Date: " + _DOCUMENTDATE+
Environment.NewLine + "Freight: " + _FREIGHT +
Environment.NewLine + "Order Number: " + GlobalRollingColumn +
Environment.NewLine + "------------------------------------------" ;
return true;
GBL_EMAIL_SUCCESS_LOG = GBL_EMAIL_SUCCESS_LOG & Environment.NewLine & "Customer PO Number: " & _CUSTOMERPONUMER & Environment.NewLine & "Customer Number: " & _CUSTOMERNUMBER & Environment.NewLine & "Document Date: " & _DOCUMENTDATE & Environment.NewLine & "Freight: " & _FREIGHT & Environment.NewLine & "Order Number: " & GlobalRollingColumn & Environment.NewLine & "------------------------------------------" return true

- To send a failure email
Add Task >> Integration Post Tasks >> Task that run if the integration fails >> New Task >> Send Email
Give Name >> SEND_EMAIL_FAILURES >> Add the below content into the Body.
Map ID: GlobalMapID Map Description: GlobalMapDescription Run Number: GlobalRunNumber Run Date: GlobalRunDate Run By: GlobalUserID Total Record Count: GlobalProcessCount Success Record Count: GlobalSuccessCount Failure Record Count: GlobalErrorCount =============================== Success Records: GBL_EMAIL_SUCCESS_LOG =============================== Failures Records: GBL_EMAIL_FAILURE_LOG =============================== Error List: GBL_EMAIL_ERROR_LOG ===============================

- To send a success email
Add Task >> Integration Post Tasks >> Task that run if the integration succeeds >> New Task >> Send Email
Give Name >> SEND_EMAIL_SUCCESS >> Add the below content into the Body.
Map ID: GlobalMapID Map Description: GlobalMapDescription Run Number: GlobalRunNumber Run Date: GlobalRunDate Run By: GlobalUserID Total Record Count: GlobalProcessCount Success Record Count: GlobalSuccessCount Failure Record Count: GlobalErrorCount =============================== Success Records: GBL_EMAIL_SUCCESS_LOG ===============================

Happy Integrating!
Have a question? Please reach out to us at support@eonesolutions.com