Created
September 8, 2019 07:38
-
-
Save naveenvm93/389e7f3a480443512873aa404232c53d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script runat="server"> | |
Platform.Load("Core","1.1.1"); | |
var output = ""; | |
var i; | |
var dataRows= Platform.Function.LookupRows('Automation_Status','Flag','True'); | |
if(dataRows && dataRows.length > 0) | |
{ | |
for(i=0; i<dataRows.length; i++) | |
{ | |
var automationCustomerKey = dataRows[i]["Customer_Key"]; | |
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", "Name"); | |
Platform.Function.AddObjectArrayItem(rr, "Properties", "Status"); | |
Platform.Function.AddObjectArrayItem(rr, "Properties", "ScheduledTime"); | |
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); | |
var Name = automationResultSet[0]["Name"]; | |
var Status = automationResultSet[0]["Status"]; | |
var ScheduledTime = automationResultSet[0]["ScheduledTime"]; | |
if (ObjectId != "null") | |
{ | |
if (Status == "-1") | |
var Print = 'Error'; | |
else if (Status == "0") | |
var Print = 'BuildingError'; | |
else if (Status == "1") | |
var Print = 'Building'; | |
else if (Status == "2") | |
var Print = 'Ready'; | |
else if (Status == "3") | |
output += "<br>" + " Status: " + "Running"; | |
else if (Status == "4") | |
var Print = 'Paused'; | |
else if (Status == "5") | |
output += "<br>" + " Status: " + "Stopped"; | |
else if (Status == "6") | |
var Print = 'Scheduled'; | |
else if (Status == "7") | |
var Print = 'Awaiting Trigger'; | |
else | |
var Print = 'InactiveTrigger'; | |
output += "<br>" + " Automation Name : " + Name; | |
output += "<br>" + " Status: " + Print; | |
output += "<br>" + "ScheduledTime: " + ScheduledTime; | |
/* | |
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"; | |
} | |
var updateResults = Platform.Function.UpsertData("Automation_Status", ["Customer_Key"],[automationCustomerKey] ,["Automation_Name","Status","ScheduledTime"], [Name, Print,ScheduledTime]); | |
} | |
Write("<br>" + output); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment