Adobe Campaign, Marketing Automation

ACC | All about variables in Adobe Campaign

Adobe Campaign post

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.

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)

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 solving problems, automating processes, and driving innovation in my clients' marketing platforms.

I hold certifications in Adobe Campaign v6 (3x certified) and Salesforce Marketing Cloud (5x certified).

Additionally, I serve as a community advisor for Adobe Campaign, offering expert insights and guidance.

In addition to my professional pursuits, I also enjoy exploring various programming languages, CMSs, and frameworks, further 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

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

SFMC TIP | Open a case

less than a minute read

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
Queries in SSJS and AMPScript
Marketing Automation, Salesforce Marketing Cloud

Query data extensions with SSJS and AMPScript

1 minute read

There’s another topic for which official documentation often lacks sufficient information, but it can be incredibly useful when needed. It’s important to note that in AMPScript, we use the data extension name to reference the table for any query. On the other hand, in SSJS, we utilize the data extension’s external key to reference the […]

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

ACC TIP | Export connection strings

less than a minute read

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

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
Salesforce Marketing Cloud Tips
Marketing Automation, Salesforce Marketing Cloud, SFMC Tips & Tricks

Troubleshooting issues with Data Extensions

1 minute read

There are other aspects that I find rather unknown; while there is likely a rational explanation, the platform doesn’t provide straightforward answers. Here are some learnings of mine while working with data extensions: Importing in Contact Builder throws a validation error on the date field. The same file has been successfully imported via Email Studio.

Continue reading