Retrieve an Automation's status verified

Learn how to retrieve an Automation's status in Salesforce Marketing Cloud (SFMC) with SSJS (server-side JavaScript). Code snippets include the WSProxy method.

WSProxy

var api = new Script.Util.WSProxy();

var name = "MyAutomation";

var request = api.retrieve("Automation", ["Name", "CustomerKey", "Status"], {
    Property: "Name",
    SimpleOperator: "equals",
    Value: name
});

var result = request.Results[0].Status;
<script runat="server">

    Platform.Load("core", "1");

    var api = new Script.Util.WSProxy();

    api.setClientId({
        "ID": Platform.Function.AuthenticatedMemberID(),
        "UserID": Platform.Function.AuthenticatedEmployeeID()
    });
	
	try {

        var name = "MyAutomation";

        var request = api.retrieve("Automation", ["Name", "CustomerKey", "Status"], {
            Property: "Name",
            SimpleOperator: "equals",
            Value: name
        });

        var result = request.Results[0].Status;

        Write(Stringify(result));
		
	} catch(error) {
        Write(Stringify(error));
    }	

</script>
2

Automation statuses

CodeStatus typeMessage
-1ErrorProgram errored out
0BuildingErrorProgram errored out during building
1BuildingProgram building with activities, schedules, and other elements
2ReadyProgram ready to start
3RunningProgram running
4PausedProgram paused from running state
5StoppedProgram stopped
6ScheduledProgram scheduled
7Awaiting TriggerProgram waiting for a trigger
8Inactive TriggerProgram trigger inactive

Reference

Ressources and references related to the current methods.

Official documentation
Check trigger status
SOAP object

Last Updated: