I have the below SSJS which gives the status of scheduling in automation. But it doesn't give the status of automation:

For example, if my automation errored, then am getting the status '6' which is scheduled instead of status '-1'. This status '6' is scheduled status of my automation .But i need the running status which is '-1' here.

Thanks for your help in advance!


<script runat="server">
var output = "";

var automationCustomerKey = "automationextrnalkey"

var rr = Platform.Function.CreateObject("RetrieveRequest");
Platform.Function.SetObjectProperty(rr, "ObjectType", "Automation");
Platform.Function.AddObjectArrayItem(rr, "Properties", "ProgramID");
Platform.Function.AddObjectArrayItem(rr, "Properties", "CustomerKey");
Platform.Function.AddObjectArrayItem(rr, "Properties", "Status");

var sfp = Platform.Function.CreateObject("SimpleFilterPart");
Platform.Function.SetObjectProperty(sfp, "Property", "CustomerKey");
Platform.Function.SetObjectProperty(sfp, "SimpleOperator", "equals");
Platform.Function.AddObjectArrayItem(sfp, "Value", automationCustomerKey);

Platform.Function.SetObjectProperty(rr, "Filter", sfp);

var retrieveStatus = [0,0,0];

var automationResultSet = Platform.Function.InvokeRetrieve(rr, retrieveStatus);
//output += "<br>automationResultSet: " + Stringify(automationResultSet);

var ObjectID = automationResultSet[0]["ObjectID"];
var Status = automationResultSet[0]["Status"];

if (ObjectID != "null") {

    output += "<br>" + automationCustomerKey + " ObjectID : " + ObjectID;
    output += "<br>" + automationCustomerKey + " Status: " + Status;

    Code Status
    -1   Error
     0   BuildingError
     1   Building
     2   Ready
     3   Running
     4   Paused
     5   Stopped
     6   Scheduled
     7   Awaiting Trigger
     8   InactiveTrigger

} else {
  output += "<br>" + automationCustomerKey + " not found";


Write("<br>" + output);


1 Answer 1



Since you are setting this up on a CloudPage, an easier approach would be to call the AutomationInstance object using WSProxy, which should retrieve all the automation runs with its statuses:

<script runat="server">


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

  var cols = ["Name","Status"];
  var filter = {
      Property: "CustomerKey",
      SimpleOperator: "EQUALS",
      Value: "automationCustomerKey"
  var res = prox.retrieve("AutomationInstance", cols, filter);

  • Thanks for sharing your solution @zuzannamj. If you look at the values resulting in the cloud page, these status are for status of scheduling but not the status of running automation. For example, if the automation is paused, and if you run once on the automation and throwed an error. Then this SSJS will show as paused state instead of error. Am looking for error state in this scenario. Can you please help here.
    – Naveen VM
    Oct 16, 2019 at 10:25
  • I have updated my answer
    – zuzannamj
    Oct 16, 2019 at 12:58
  • Awesome @zuzannamj. Thank you so much for pointing it to right object :)
    – Naveen VM
    Oct 17, 2019 at 5:52
  • 1
    Please note though that AutomationInstance will display the oldest runs first, so since the return limit is 2500ish (I think) so if your automation has run over that many times, the latest run will not be in your response. You can try creating a complex filter around date to handle this, or set up your call for pagination based on 'HasMoreRows' property to ensure you get all the data available Oct 17, 2019 at 20:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .