Retrieving and Starting an Automation with SSJS

Server-side Script (SSJS) Activities are a hidden gem of the Salesforce Marketing Cloud. They’re useful for a wide range of applications. I ran into a scenario where I wanted to run an Automation programmatically — if it’s not already running.

It was way harder than it needed to be. Hope this saves you some frustration:

The retrieve is for getting the ObjectID and Status of the Automation, which you then use to check to see if it’s running and then invoke a Perform if it isn’t.

The frustrating part of this was that the ObjectID is not a retrievable property of the Automation Object (unlike Status). It’s only returned in the result-set of a successful Retrieve.

I’d suggest testing this script in a Landing Page until you get it working and then move it to the Script Activity.

SFMC Support can enable Script Activities if there’s not a Script entry in the Interactions drop-down menu.

For further reading:

(Visited 8,849 times, 1 visits today)
guest
51 Comments
Oldest
Newest
Inline Feedbacks
View all comments