I was able to run an automation which is in "scheduled" staus using SSJS, but when I pause it manually (status changed to "Paused") and execute the same script, the automation doesn't run. The script executes without any errors.

I have tried this in Script Activity and a Landing page, but don't know if I am missing something here.

Has anyone come across a similar issue before?

<script runat="server">
var automationCustomerKey = "customer-key"
// Search for an automation
var filter = {Property:"CustomerKey",SimpleOperator:"equals",Value:automationCustomerKey};
var automationObject = Program.Retrieve(filter);
// Start automation if not "Running"
if (3 != automationObject[0].Status) {
    Write("Current Status: " +automationObject[0].Status+"\n");
    var automationPerformed = Program.Init(automationCustomerKey);
else {
    Write("Current Status: " +automationObject[0].Status);

When an automation is in a paused state it is designed to not be able to run via the normal function/API requests. In order to make this run, you need to include the Steps and Activities inside of it that you want to run, similar to utilizing the 'run once' feature inside of the UI.

So for example, in a SOAP perform request, you need to include:

    <PerformRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
            <Definition xsi:type="Automation">
                    <IsIncludedInRun> true</IsIncludedInRun>

This will then let you perform the single instance run on a paused automation. To simplify things there is a REST endpoint for retrieving an automation AND a rest endpoint for starting it, so you can skip the SOAP if you want.

REST Retrieve Automation Endpoint: /automation/v1/automations/{{AutomationID}}

This will return the 'steps' array you need for the start endpoint.

For example, something like:

var res = HTTP.POST(endpoint,contentType,headerNames,headervalues);
var steps = Platform.Function.ParseJSON(res.Response[0]).steps;

You would then use the IDs from the steps/activities in the second call.

REST Start Automation Endpoint: /automation/v1/automations/{{AutomationID}}/actions/start

You push in the steps array you had from the previous retrieve and make sure to add in the property "IsIncludedInRun": true for all the steps/activities you want run or IsIncludedInRun": false for those you do not want run.

For example:

    "steps": [
            "activities": [
                    "id": "{{ActivityID}}",
                    "IsIncludedInRun": true

This will then let you run a Paused Automation. Do note though, that the id of the activity is required in the Start endpoint and it cannot use Key or Name as a substitute.

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.