Please provide the solution on pausing the automation . Thanks, Disha", "answerCount": 1, "upvoteCount": 1, "datePublished": "2021-11-16T09:52:14.000Z", "author": { "@type": "Person", "name": "Disha Jain", "url": "https://trailblazers.salesforce.com/profileView?u=0054S000001AUNOQA4", "affiliation": { "@type": "Organization", "name": "Accenture" } }, "suggestedAnswer": [ { "@type": "Answer", "text": "Hi Disha, Did you try work with the ScheduleOption object and the ScheduleRequest action?", "upvoteCount": 0, "url": "https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000DwXRdSAN", "datePublished": "2021-12-16T20:04:19.000Z", "author": { "@type": "Person", "name": "Agustin Rodriguez", "url": "https://trailblazers.salesforce.com/profileView?u=0053A00000FMZj6QAH", "affiliation": { "@type": "Organization", "name": "Devs United" } } } ] } } Skip to main content

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

 

#Salesforce Developer

 

@* Salesforce Developers *

1 件の回答
  1. 2021年12月16日 20:04

    Hi Disha, Did you try work with the ScheduleOption object and the ScheduleRequest action?

0/9000