I have written the below code and created one test scheduled automation to start the automation. I didn't get any error when i did scheduled/publish the code but my automation is not starting. and i can see status as '2' which is ready state.

<script language="javascript" runat="server">
  Platform.Load("core", "1.1.1");
var cid = Platform.Function.CreateObject("ClientID");
Platform.Function.SetObjectProperty(cid, "ID", "XXXXXXXX");
Platform.Function.SetObjectProperty(cid, "IDSpecified", "true")

var rr = Platform.Function.CreateObject("RetrieveRequest");
Platform.Function.AddObjectArrayItem(rr, "ClientIDs", cid);
Platform.Function.SetObjectProperty(rr, "ObjectType", "Program");
Platform.Function.AddObjectArrayItem(rr, "Properties", "Name");
Platform.Function.AddObjectArrayItem(rr, "Properties", "ObjectID");
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", "TestRUN");

Platform.Function.SetObjectProperty(rr, "Filter", sfp);

var retrieveStatus = [0,0,0];

var automationResultSet = Platform.Function.InvokeRetrieve(rr, retrieveStatus);

 var automationObjectID = automationResultSet[0]["ObjectID"];
 var automationStatus = automationResultSet[0]["Status"];
Write("\n object ID::"+automationObjectID);
if (automationObjectID != "null") {
Write("in objectid if");
      var obj = Platform.Function.CreateObject("Program");
        Platform.Function.SetObjectProperty(obj, "ObjectID", automationObjectID);
//  Platform.Function.AddObjectArrayItem(obj, "ClientID", cid);
        var po = Platform.Function.CreateObject("PerformOptions");

        var performResult = [0,0,0];
        var performStatus = Platform.Function.InvokePerform(obj, "start", performResult, po);

} else {
    Write(Stringify("automation not found"));

I would use the API:

Note that you will need to retrieve your access_token and of course the ObjectID of the automation first.

<script runat="server">
Platform.Load("Core", "1")
// Call Automation in Child BU
var url = 'https://webservice.s10.exacttarget.com/Service.asmx';
var contentType = 'text/xml; charset=UTF-8';
var headerNames = ["SOAPAction"];
var headerValues = ["Perform"];
var access_Token = "YOUR ACCESS TOKEN FOR THE API";
var automationObjectId = "YOUR AUTOMATION'S OBJECT ID";

payload= '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">'
payload+= '   <s:Header>'
payload+= '   <fueloauth xmlns="http://exacttarget.com">' + access_token + '</fueloauth>'
payload+= '   </s:Header>'
payload+= '   <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">'
payload+= '        <PerformRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">'
payload+= '            <Action>start</Action>'
payload+= '            <Definitions>'
payload+= '                <Definition xsi:type="Automation">'
payload+= '                    <ObjectID>' + automationObjectId +'</ObjectID>'
payload+= '                </Definition>'
payload+= '            </Definitions>'
payload+= '        </PerformRequestMsg>'
payload+= '   </s:Body>'
payload+= '</s:Envelope>'

var result = HTTP.Post(url,contentType,payload,headerNames,headerValues);
var statusCode = result["StatusCode"];
var performResponse = result["Response"][0];
performResponse = Stringify(performResponse).replace(/[\n\r]/g, '');

This is best achieved with WSProxy. The tricky part is you need the ID of the Automation, which is only accessible via the API, by requesting the ProgramID. This will return you the ObjectID, which is what you need. The other key part is the setClientId function which switches to a different BU context. You will be able to access automations in child BU from the parent BU and the reverse, from child to parent, but don't think you won't be able to go from child BU to child BU.

<script  runat="server">

    var prox = new Script.Util.WSProxy();

    //Switch context to different BU. Change the MID to suit.
    prox.setClientId({ "ID": 123456789 });

    // Need to retrieve the ObjectID for the Automation, which isn't available via the SFMC interface.
    var cols = ["Name", "ProgramID", "IsActive"];
    var filter = {
        Property: "Name",
        SimpleOperator: "equals",
        Value: "Name of your automation"
    var desc = prox.retrieve("Automation", cols, filter);

    // Output ObjectID if you want to see it. 
    Write('<br>ObjectID: ' + desc.Results[0].ObjectID);

    var props = {
        ObjectID: desc.Results[0].ObjectID
    var action = "start";
    var opts = {};
    var res = prox.performItem("Automation", props, action, opts);
    var status = res.Status;
    var statusCode = res.Results[0].StatusCode;

    Write("status code: " + statusCode);

    //reset the context if required

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.