Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save katydorjee/54d25e89a9af43bc81514550b13386ed to your computer and use it in GitHub Desktop.
Save katydorjee/54d25e89a9af43bc81514550b13386ed to your computer and use it in GitHub Desktop.
<script runat="server">
Platform.Load("core","1.1.1");
var prox = new Script.Util.WSProxy();
/*
//Child BU's MID
var MID = 10000000000;
//Switch context to different BU. Change the MID to suit.
prox.setClientId({ "ID": MID });
*/
// 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: "API trigger test"
};
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);
</script>
@katydorjee
Copy link
Author

Refer an Older version of code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment