I am using the below SSJS WSproxy code to extract the automation details like name, status,start time etc. to create a dashboard
<script runat="server">
Platform.Load("Core","1");
var prox = new Script.Util.WSProxy();
var cols = ["Name","Status","StartTime","AutomationID"];
var filter1 = {
Property:"Name",
SimpleOperator:"EQUALS",
Value: "My_Test_Automation"
};
var res = prox.retrieve("AutomationInstance",cols,filter1);
if (res.Results.length > 0) {
var statusObj = {
"-1":"Error",
"0":"BuildingError",
"1":"Building",
"2":"Ready",
"3":"Running",
"4":"Paused",
"5":"Stopped",
"6":"Scheduled",
"7":"Awaiting Trigger",
"8":"InactiveTrigger"
}
Write('<table align="center" border="1" cellpadding="5" ><tr><th colspan="3">Automation Dashboard</th></tr>')
for (var i = 0; i < res.Results.length; i++) {
var autoName = res.Results[i].Name;
var autoStatusNum = res.Results[i].Status;
var autoStatus = statusObj[autoStatusNum];
var StartTime = res.Results[i].StartTime;
var ID = res.Results[i].AutomationID;
Write('<tr><td>' + autoName + '</td><td>' + autoStatus + '</td></tr>'+'<tr><td>' + StartTime+'<tr><td>' + ID)
}
Write('</table>')
}
</script>
I am referring the SFMC documentation to extract the properties of AutomationInstance object - https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/automationinstance.html
I am facing following issues -
- I can fetch a single automation details right now as I am using a filter but I would like to extract all automation available in the BU. Please can anyone let me know how I can do this by modifying the filter or the code?
- I am able to get values for all the properties but for
AutomationID
it returns null. Please can someone point out what I am doing wrong here?