SFMC | How to Run an Automation on a Loop

Automation studio, Salesforce Marketing Cloud
2 minutes read#automation studio #ssjs

As many of us are aware, automation in the Salesforce Marketing Cloud can only be scheduled to run at minimum once per hour. While this frequency may suffice for most automations created within the Automation Studio, there are instances where we may require an automation to run continuously, immediately after it completes its previous run.

To accomplish this, we will utilize a while loop and create two automations. The primary automation will act as the worker and execute the necessary tasks, while the secondary automation will solely serve to trigger the worker automation to restart the processing cycle.

This approach is particularly beneficial when handling Data Extensions with an extensive number of rows, often resulting in a run timeout if processed in one go. Alternatively, this method can be utilized in any other applications that necessitate immediate execution.

Prerequisites

Add following columns to data extension that will be processed in batches:

  • processed as Boolean
  • processed_at as date
Worker automation

Main automation that will process Data extension with a lot of data will consists of following activities.

  • query activity to take portion of data from the data extension you want to process in loop
  • verification activity – to finish automation while loop when there is no data to process
  • activities to process actual records taken into actual loop
  • mark records as processed so they wont be processed again in the original data extension
  • call the caller – this is script using to call other automation. For this you can find wast examples on the internet. You can achieve same with WSProxy or with platform function InvokePerform. Example can be found on stackexchange.
//InvokePerform simplified example
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);

//ws proxy sipmlified example
var WSProxy = new Script.Util.WSProxy();
WSProxy.performItem("Automation", { CustomerKey: customerKey }, "start");
Caller automation

Caller automation will consist of wait activity to make sure our worker automation is finished before we called it back to run again. And the script itself that runs the worker automation with method described earlier.

Good to know
  • Do not configure scheduler leave it blank. If you do so the automation could not be called from script
SFMC tips and tricks
Marketing Automation, Salesforce Marketing Cloud, SFMC Tips & Tricks

SFMC TIP | Google Analytics Integration 1

less than a minute read#AMPScript #email studio #Google Analytics #journey builder

When you integrate with Google Analytics, marketing cloud will add tags to all your links. When this happens, all dynamic links will be broken. Links that are defined programmatically as variable, field or attribute with GA integrated will look as if the tracking link also appends google analytics tags. This will make such link not […]

Continue reading
SFMC tips and tricks
Marketing Automation, Salesforce Marketing Cloud, SFMC Tips & Tricks

SFMC TIP | Open a case

less than a minute read#case #support

As the title says open a case every time you experience issue or some feature you used on another instance and now is gone. Why open a case? For example when you automation fails with detailed error “Error has occurred”. Simple solution is to “open a case”. Support will tell you exactly what happened. You […]

Continue reading
SFMC tips and tricks
Marketing Automation, Salesforce Marketing Cloud, SFMC Tips & Tricks

SFMC TIP | Data views for transactional emails

1 minute read#data views #SQL

Data views in Salesforce Marketing Cloud are very handy, when it comes to getting data insights from various sources inside the platform. I will give you a quick start on how to get data insights for you transactional emails using data views. We will use data from _Sent, _Job, and _Subscriber view s.TriggererSendDefinitionObjectID – object […]

Continue reading
SFMC tips and tricks
Marketing Automation, Salesforce Marketing Cloud, SFMC Tips & Tricks

SMFC TIP | NULL value comparison in IF statement

less than a minute read#AMPScript #cloud page #email template #programming

If you have field in DE that its value is not always populated for a particular row (customer) and you test field value against any value cloud page will throw an 500 – internal server error. To fix this you will need to add another AND-condition to test field value for NULL

Continue reading
Adobe campaign tips and tricks
ACC Tips & Tricks, Adobe Campaign, Marketing Automation

ACC TIP | Escalate user rights

1 minute read#JavaScript #programming #webapp

Normally web apps run under the web app user (which is anonymous and has very little to zero rights by default) and for certain operations you would need to require to grant additional access, or even grant full admin. To grant full admin for web app user is not solution to go with. Instead I […]

Continue reading
SFMC tips and tricks
Marketing Automation, Salesforce Marketing Cloud, SFMC Tips & Tricks

SFMC TIP | Invalid links in HTML

1 minute read#AMPScript #programming

When the HTML template is used (loading your own HTML code) all the links that use query parameters (?a=b) will resolve to invalid links when they redirect upon user click. This happens when web analytics UTM tags are being attached to the delivery. To resolve this issue all the links with additional query parameters has […]

Continue reading
Link campaign to the delivery send in salesforce marketing cloud
Salesforce Marketing Cloud

SFMC | Link campaign to delivery send

3 minutes read#data views #programming #SQL #ssjs

Are you aware of Salesforce Marketing Cloud’s additional marketing feature known as Campaign? This tool allows you to group similar journeys together, providing greater organization for your marketing activities. However, one drawback is that the campaign information is not available in the data views. While waiting for a fix from Salesforce, you can establish a […]

Continue reading
SFMC tips and tricks
Marketing Automation, Salesforce Marketing Cloud, SFMC Tips & Tricks

SFMC TIP – Double quotes in AMPScript break email template

less than a minute read#AMPScript #email template

Very recently I have found that when I add any AMPScript function to eg. button URL field SFMC will just ignore everything that follows after the first occurrence of the double quote. Simple fix is to use single quotes instead.

Continue reading
Adobe campaign tips and tricks
ACC Tips & Tricks, Adobe Campaign, Marketing Automation

ACC TIP | Export connection strings

less than a minute read#configuration #xml

Whether you change your laptop or want to save actual configuration for your colleagues. You can easily achieve that by taking all connection strings as XML. ims – connection over adobe id SSO Also similar approach is to directly change the connection string file nlclient_cnx.xml that is located under your local AppData folder. To quickly […]

Continue reading