I have used below Code to pause it, but it is stopping it actually instead of pausing it permanently and makes it active before the next run.
<script runat="server"> Platform.Load("core","1.1.5");
var SourceDE = DataExtension.Init("Auto_to_Pause").Rows.Retrieve(); for(var m=0; m<SourceDE.length; m++) { var AutomationName = SourceDE[m].AutomationName; var AutomationExternalKey = SourceDE[m].AutomationExternalKey; var rr = Platform.Function.CreateObject("RetrieveRequest"); Platform.Function.SetObjectProperty(rr, "ObjectType", "Automation"); Platform.Function.AddObjectArrayItem(rr, "Properties", "Name"); Platform.Function.AddObjectArrayItem(rr, "Properties", "CustomerKey"); Platform.Function.AddObjectArrayItem(rr, "Properties", "ProgramID"); 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", AutomationExternalKey);
Platform.Function.SetObjectProperty(rr, "Filter", sfp);
var StatusAndRequestID = [0,0]; var Result = Platform.Function.InvokeRetrieve(rr,StatusAndRequestID);
var AutomationObjectID = Result[0].ObjectID; var obj = Platform.Function.CreateObject("Automation"); Platform.Function.SetObjectProperty(obj, "ObjectID", AutomationObjectID); var po = Platform.Function.CreateObject("PerformOptions");
var performResult = [0,0,0]; var performStatus = Platform.Function.InvokePerform(obj, "stop", performResult, po); } </script>
Please provide the solution on pausing the automation .
Thanks,
Disha
Hi Disha, Did you try work with the ScheduleOption object and the ScheduleRequest action?