A Deep Dive into Real-Time Tracking Of Automation Status In SFMC
Introduction:
Effectively monitoring the status of automations in Salesforce is crucial for ensuring seamless operations. In this blog post, we delve into an advanced approach to automation monitoring logic, providing detailed insights on how to track automations using Salesforce Marketing Cloud's API objects: Automation and AutomationInstance.
Understanding the Challenges:
Before we explore the solution, it's essential to acknowledge the challenges associated with traditional monitoring methods. The advanced audit trail log, while informative, fails to log the name of the automation in the message column, as discussed in this Salesforce article https://help.salesforce.com/s/articleView?id=sf.mc_rn_october_2020_setup_new_audit_trail_activites.htm&type=5.
Additionally, relying on data views (https://help.salesforce.com/s/articleView?id=sf.mc_as_data_view_automation_instance.htm&type=5) requires waiting 24-48 hours to access the necessary details.
The Solution: Leveraging API Objects
To overcome these challenges, we recommend utilizing the API objects Automation and AutomationInstance along with the provided Server-Side JavaScript (SSJS) script.
Sample SSJS Script:
<script runat="server"> Platform.Load("Core", "1.1.1"); var output = ""; var i; var dataRows = Platform.Function.LookupRows('<Data_Extension_Name>', 'Flag', 'True'); if (dataRows && dataRows.length > 0) { for (i = 0; i < dataRows.length; i++) { // Retrieving automation details var automationCustomerKey = dataRows[i]["Customer_Key"]; var rr = Platform.Function.CreateObject("RetrieveRequest"); // Adding properties to retrieve // ... // Applying a filter based on CustomerKey // ... // Invoking retrieve and processing results var retrieveStatus = [0, 0, 0]; var automationResultSet = Platform.Function.InvokeRetrieve(rr, retrieveStatus); // Extracting relevant automation details // ... // Mapping numeric status to human-readable labels var Print = mapStatusToLabel(Status); // Updating monitoring list with the latest details var updateResults = Platform.Function.UpsertData("<Data_Extension_Name>", ["Customer_Key"], [automationCustomerKey], ["Automation_Name", "Status", "ScheduledTime", "AutomationID", "AutomationType", "CompletedTime", "CreatedDate", "ModifiedDate", "StartTime", "StatusLastUpdate", "StatusMessage"], [Name, Print, ScheduledTime, AutomationID, AutomationType, CompletedTime, CreatedDate, ModifiedDate, StartTime, StatusLastUpdate, StatusMessage]); } Write("<br>" + output); } </script>
Conclusion:
By incorporating the above SSJS scripts and leveraging the Automation and AutomationInstance API objects, you can enhance your automation monitoring capabilities. This detailed guide provides a comprehensive solution to efficiently track and manage automation statuses in Salesforce Marketing Cloud.
Comments
Post a Comment