Contact Us

November 20, 2024

June 17, 2026 6:34 pm

Fixing automation error status in Salesforce Marketing Cloud

Share with

Understanding the Problem

The main Automation object in Salesforce Marketing Cloud returns to a Scheduled status for the next scheduled run, even if an error has occurred previously. This can make it difficult to determine the actual status of the automation.

The root cause of this issue is the way the Automation object handles status updates. When an error occurs, the status is not updated correctly, leading to incorrect status displays.

Fixing the Issue

To fix this issue, you can use the AutomationInstance object to retrieve the status of the automation. The AutomationInstance object provides more detailed information about the automation, including the StatusMessage, which can be used to determine if an error has occurred.

AutomationInstance.js

var prox = new Script.Util.WSProxy();
prox.setClientId({'ID': midCurr }); // impersonate mid
var errCount = 0;
var excessActivities = 0;
var cols = ['ProgramID','Notifications','Name'];
var filter = {
    Property: 'Status',
    SimpleOperator: 'IN',
    Value: [3,6,7] // running, scheduled, or waiting for trigger
};
var automations = prox.retrieve('Automation', cols, filter);
// check if 'running, scheduled, or waiting for trigger' automations exist
var exist = automations.Results[0].PartnerProperties[0].Name == 'ErrorMessage' &&
                  automations.Results[0].PartnerProperties[0].Value == 'No rows were found' ?
                  false : true;
if (exist) {
  for (j = 0; j < automations.Results.length; j++) { 
    cols = ['Status','StatusLastUpdate'];
    var objId = automations.Results[j].ObjectID;
    filter = {
        Property: 'AutomationID', 
        SimpleOperator: 'equals',
        Value: objId
    };
    var instance = prox.retrieve('AutomationInstance', cols, filter);
    var autoIndex = instance.Results.length - 1; // get instance when automation run
    var statusMsg = instance.Results[autoIndex].StatusMessage;
    if (statusMsg && statusMsg!='Complete') { // ignore automations that have not run
      errCount += 1;
    }
  }
}

This code snippet demonstrates how to use the AutomationInstance object to retrieve the status of an automation and check for errors.

Best Practices

Heads up: When working with automations in Salesforce Marketing Cloud, it is essential to use the correct objects and fields to retrieve accurate status information.

Checklist for Troubleshooting Automation Errors

  • Use the AutomationInstance object to retrieve the status of an automation
  • Check the StatusMessage field to determine if an error has occurred
  • Use the correct filter and columns when retrieving automation data
  • Impersonate the correct mid when using WSProxy
  • Handle errors and exceptions properly in your code
  • Test and debug your code thoroughly to ensure accurate results

What is the AutomationInstance object?

The AutomationInstance object is a Salesforce Marketing Cloud object that provides detailed information about the status of an automation.

How do I retrieve the status of an automation using the AutomationInstance object?

You can retrieve the status of an automation using the AutomationInstance object by using the retrieve method and specifying the correct filter and columns.

What is the StatusMessage field used for?

The StatusMessage field is used to determine if an error has occurred during the execution of an automation.

How do I handle errors and exceptions when working with automations in Salesforce Marketing Cloud?

You should handle errors and exceptions properly in your code by using try-catch blocks and logging error messages to ensure accurate results and debugging.

What are some best practices for troubleshooting automation errors in Salesforce Marketing Cloud?

Some best practices for troubleshooting automation errors include using the correct objects and fields, handling errors and exceptions properly, and testing and debugging your code thoroughly.

Genetrix Technology · Salesforce Marketing Cloud Partner

Need help shipping this in production?

Genetrix builds and untangles Salesforce Marketing Cloud and Agentforce setups for teams that want it done right the first time. If anything in this post sounds familiar, talk to us before it ships.

Get in Touch with Genetrix →

Blogs for the

Business-Savvy!​

Let’s Connect

A 30 min no cost strategy session
with cloud support expert

Let’s Connect

A 30 min no cost strategy session
with cloud support expert