ACC | All about variables in Adobe Campaign

in  Adobe Campaign, Marketing Automation
2 minutes read

In this article I will explain all sorts of variables you can come across when working with the tool. Also I will discuss different less known approach of storing variables.

Workflow variables

In adobe campaign we have way how to store variables between consecutive activities. Normally you would store variables as instance or context variables. What if I told you there is more unconventional way how to store them.

Inside workflows we can store variables in one activity and use them later when needed in activities that follows.

You can define two types of workflow variables

instance.vars.myVar
vars.myVar

instance.vars.xx can be accessed in all activities in the workflow from the point of declaration.

vars.xx can be accessed only by activities that follow after the declaration.

All looks good until you realize that these variables can only hold string values. To store objects in workflow variable you need to use JSON.stringify and JSON.parse everytime, you want to use or save them before move to another activity in your workflow. Also there are limits on what data you can stringify.

Web application variables

In the webapps you will come accross context variables and they work similarly to instance variables in the worklfows.

ctx.vars.myVar

Variables can be accessed on server side as well on client side

document.controller.setValue('/ctx/vars/myVar', 'some value');
var myVar = document.controller.getValue('/ctx/vars/myVar');

Same as for workflow you need to stringify variables if you are using them for objects.

Custom variables workaround

In workflows you are able to pass variables as their original type (object especially) with use of javascript library on properties level (global level) or using loadLibrary JSAPI function with option to enable cache. This way the variables added to your library will be cached and can be accessed in your workflow

loadLibrary('myLibrary.js')


This way I do not have to stringify objects but move then between activities and access them as objects everywhere else.

How to?

  • Add java script library to your web app
  • JS Script library contains simple object declaration. I called it DL like data layer don’t ask me why
//DL object initialization in the library loaded to the workflow
DL = {};
  • In any place of your workflow use it
//initialize your object variable in any script or 
//in initialization script on advanced tab of any activity
DL.myVar = {a:2,b:3};
//use it in another activity
var myVarLocal = DL.myVar

Remarks:

  • Every wait or jump activity will reset the DL object to keep your object intact after wait or jump you need to store the DL object to the instance variables
  • Everytime your workflow is paused due to an error
//store it locally in wait activity's advanced tab
instance.vars.DL = JSON.stringify(DL.myVar)

//load it again after wait
DL.myVar = JSON.parse(instance.vars.DL);
in  Automation studio, Salesforce Marketing Cloud

SFMC | Automation run on loop

2 minutes read

We all know very well, that automation can be scheduled the minimum-you-can-set once per an hour. This may satisfy mostly of automation we might build in our automation studio but sometimes we want to run automation again and again just as it finishes its previous run. To achieve that we will create while loop with […]

Continue reading