Adobe Campaign, Marketing Automation

All about variables in Adobe Campaign

All about variables in Adobe Campaign

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.
Example of how workflow variables works.

You can also reference them inside any condition e.g. in split, enrichment, query, test activity by adding following to the expression:

$(instance/vars/@myVar)
$(vars/@myVar)

// in case of using included in you can simple use 
// $noescaping to create valid in condition
// vars.myVar = "1,2"

$noescaping(vars/@myVar) 

//will create in (1,2) instead ("1,2") when $noescaping is not used

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.

These variables are not visible on the client side, however you can set and read them if needed on the client side inside <script>. I have not tested how secure it is but I guess you are able to change these variables on fly and then feed them into the form submission.

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);

Oh hi there 👋
I have a FREE e-book for you.

Sign up now to get an in-depth analysis of Adobe and Salesforce Marketing Clouds!

We don’t spam! Read our privacy policy for more info.

#JSSP #webapp
Marcel Szimonisz
Marcel Szimonisz
MarTech consultant As a marketing automation consultant, I specialize in problem-solving, process automation, and driving innovation for clients' marketing platforms.

I hold certifications in Adobe Campaign v6 (3x certified) and Salesforce Marketing Cloud (5x certified), as well as 1x Salesforce Associate certified.

Moreover, I serve as a community advisor for Adobe Campaign, providing expert insights and guidance.

Beyond my professional pursuits, I explore various programming languages, CMSs, and frameworks, enhancing my technical expertise and staying at the forefront of industry advancements.
Take a look at our subscription offering in case you are looking for a Marketing Automation Consultant.

Leave a comment

Your email address will not be published. Required fields are marked *

Similar posts that you may find useful

How to JavaScript in SFMC
Marketing Automation, Salesforce Marketing Cloud

JavaScript in Salesforce Marketing Cloud

3 minutes read

Salesforce Marketing Cloud uses JavaScript where a advanced customization is needed e.g. automations, cloud pages and even in message personalization. Last time we discussed how to JavaScript in Adobe Campaign, we discovered that it utilizes an older version of ECMAScript. However, it’s worth noting that Salesforce Marketing Cloud (SFMC) goes even further back and employs […]

Continue reading
How to map enumeration with file extract
ACC Tips & Tricks, Adobe Campaign, Marketing Automation

How to map enumeration with file extract

1 minute read

I was recently asked about the purpose of a checkbox, and believe it or not, it turned out to be the function I thought was missing in Adobe Campaign Classic – but it’s actually there. It’s the File Extract activity feature hidden in one of the final steps of the extraction wizard. It is simple […]

Continue reading
Salesforce marketing cloud how to run an automation in a loop
Automation studio, Salesforce Marketing Cloud

How to Run an Automation in a Loop

2 minutes read

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. […]

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

NULL value comparison in IF statement

less than a minute read

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 simply need to add another AND-condition to test field value for NULL with NOT […]

Continue reading
Salesforce Marketing Cloud Tips
Marketing Automation, Salesforce Marketing Cloud, SFMC Tips & Tricks

Proof email was previewed but not received

2 minutes read

There are many possible issues, and I will try to list all those I have come across during my times when I wondered where my email is. Contact is unsubscribed If the contact you are trying to preview an email with is on one of the global unsubscribe lists, or has unsubscribed or bounced status […]

Continue reading