I am trying to retrieve status of automation instance object to see status of the last 4(in last 24 hours- since the automation runs in every 6 hours) instances of the automation. I am using the below code, but it retrieves only 3 records which are not even the last three. Not sure what is going wrong!
<script runat="server">
Platform.Load("core","1");
var prox = new Script.Util.WSProxy();
var BU = [{"marketCode": "Belgium", "mid":mid}]
for (i = 0; i < BU.length; i++) {
var mid = BU[i].mid;
prox.setClientId({"ID": mid});
}
var AutomationInstance = "AutomationInstance";
var childcols = ["CustomerKey","Status","StartTime","StatusLastUpdate"];
var childfilter = {
Property:"CustomerKey",
SimpleOperator:"EQUALS",
Value: CustomerKey
};
var childreqID = null;
var childprops = null;
var childmoreObjs = true;
// var childobjs = prox.retrieve(AutomationInstance, childcols, childfilter);
try
{
while (childmoreObjs)
{
childmoreObjs = false;
var childobjs = childreqID == null ? prox.retrieve(AutomationInstance, childcols, childfilter) : prox.getNextBatch(childobjs, childreqID);
if (childobjs != null) {
childmoreObjs = childobjs.HasMoreRows;
childreqID = childobjs.RequestID;
for (var z = 0; z <childobjs.length; z++) {
var automationInsitanceObj = childobjs.Results[z];
Platform.Response.Write("Start Time: "+automationInsitanceObj.StartTime+ " ");
Platform.Response.Write("Customer Key: "+automationInsitanceObj.CustomerKey);
}// end for
}//end if
}// end while
}// end try
catch (e) {
Platform.Response.Write("min for" + Stringify(e));
}
</script>