0

I need to have 3 sets of automation.

  1. The first one is a file drop automation.
  2. Then I have a set of 10 automations which should run after the first one completes.
  3. The final automation should run only after all the 10 automations mentioned in the previous step completes. That is, it should be triggered as the last step of whichever of the 10 automations that completes last.

Note: I cannot base it on time as it is not possible to know in advance the time taken for execution. Also i do not want to include all activities in a huge automation because there quite a lot of activities (more than 100) and it reduces understandability of the automation. I need to keep the activities related to different functions separate.

I read in this forum that SSJS is a possibility. If that is correct, can someone elaborate on how to use it to trigger automations.

  • Why don't you just run tests on the automation's to find out the worst case scenario of how long each automation takes to run in time, then schedule them sequentially to run with allowing plenty of time for them to complete. that would essentially provide you the result you are looking for right? – thechrishaddad Aug 23 '17 at 9:45
5

You can certainly check the start and status of an Automation using a SSJS Script Activity. If you don't see it in your list of Activity types, SFMC Support can enable it for you.

Here's an example that retrieves and starts an Automation if it's not already running.

<script runat="server">

Platform.Load("Core","1.1.1");

var automationCustomerKey = "CUSTOMERKEY-OF-AUTOMATION"

var rr = Platform.Function.CreateObject("RetrieveRequest");
Platform.Function.SetObjectProperty(rr, "ObjectType", "Automation");
Platform.Function.AddObjectArrayItem(rr, "Properties", "ProgramID");
Platform.Function.AddObjectArrayItem(rr, "Properties", "CustomerKey");
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", automationCustomerKey);

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

var retrieveStatus = [0,0,0];

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

var ObjectID = automationResultSet[0]["ObjectID"];
var Status = automationResultSet[0]["Status"];

if (ObjectID != "null") {

    /*
    Code Status
    -1   Error
     0   BuildingError
     1   Building
     2   Ready
     3   Running
     4   Paused
     5   Stopped
     6   Scheduled
     7   Awaiting Trigger
     8   InactiveTrigger
    */

    if (Status == 2) {

        var obj = Platform.Function.CreateObject("Automation");
        Platform.Function.SetObjectProperty(obj, "ObjectID", ObjectID);
        var po = Platform.Function.CreateObject("PerformOptions");

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

    } else {
      // already running

    }
} else {
   // automation not found
}

</script>

Some additional details here: Retrieving and Starting an Automation with SSJS

  • Add this script to the 10 step automation as step 11 – Samuel Dare Aug 23 '17 at 13:39
  • its exactly what i was looking for, proposed solution works. thanks a lot! – Aleena Thomas Nov 7 '17 at 8:24

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.