Back

Enhancing Email Format Functionality for SmartConnect 21: A Client Perspective

Published: Dec 09, 2024
Post Author Written by Amit Chaudhari

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.

Success Email Format 2
Failure Email Format

In case you’re unfamiliar with configuring email using the Microsoft Graph protocol, you can refer to this video: YouTube – Microsoft Graph Email Setup. For detailed instructions on setting up a Microsoft Graph OData connection, visit eOne Solutions Documentation.

Note: The legacy SMTP protocol for Office 365 email accounts has been deprecated. Microsoft Graph is the recommended alternative. You can find more information on setting up email with TLS in this eOne Solutions Help Article.

Steps:

  • Include the following three variables in the “Global Variables” session >> Add
GBL_EMAIL_ERROR_LOG
GBL_EMAIL_SUCCESS_LOG
GBL_EMAIL_FAILURE_LOG
global Variable screenshot Sc21
global Variable screenshot Sc21 how to add it
  • 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

Add Reset Variable 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
reset var script
  • 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

failure msg add script task

Give Name >> CAPTURE_FAILURE_MSG >> Add the below script and click on “Validate”.

These are source columns i.e. _CUSTOMERPONUMBER, _CUSTOMERNUMBER, _DOCUMENTDATE, and _FREIGHT. You can easily drag and drop them from the left side of the editor window.

If any conversions are needed, such as from double to string or number to string, you can utilize the appropriate conversion functions.
https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/functions/return-values-for-the-cstr-function

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
capture failure msg
  • 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
error log add script task

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
capture error msg
  • 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
success msg

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
script success msg
  • 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.

For Variables that are being used in the script, you can easily drag and drop them from the button “Insert Variables”.

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
===============================
failure email task
  • 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.

For Variables that are being used in the script, you can easily drag and drop them from the button “Insert Variables”.

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
===============================
success email task 1

Happy Integrating!

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

Feeling stuck? Get the support and guidance you need to help you power through any data challenge

We're on your integration team. Connect with our people and let us know how we can help you.