Forked from jdeblank/ssjs_wsproxy_StartAutomation.js
Last active
May 17, 2020 08:12
-
-
Save katydorjee/54d25e89a9af43bc81514550b13386ed 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 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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Refer an Older version of code