Expand my Community achievements bar.

We are excited to introduce our latest innovation to enhance the Adobe Campaign user experience — the Adobe Campaign v8 Web User Interface!
SOLVED

How to keep the value of global variable defined in a wkf after it ends

Avatar

Level 5

Hi,

May anyone tell me how to keep the value of a global variabile (es. vars.numErrors) defined inside a workflow after the workflow ends its execution?
Note that the status of the workflow is always STARTED because of an external signal.

vars.numErrors is modified inside a javascript activity like that:

if(vars.numErrors == null || vars.numErrors==""){

  vars.numErrors = 0;

}

var numErr = vars.numErrors;

numErr++;

vars.numErrors = numErr;

logInfo("Numero errori: "+numErr);

In current situation, after each execution vars.numErrors will be equal to 1, while I want it to be 1,2,3....

Does it exist a global variable that has a scope greater than the workflow?

Could you suggest me a solution that don't required an SQL table?

Thanks,

Salvatore

Jean-Serge Biron

@nkur

Adhiyan

kirti.rawat

Adobe Campaign

1 Accepted Solution

Avatar

Correct answer by
Level 10

Buon giorno Salvatore,

Please use xtk:options for this kind of storage, out of the scope of instance.vars.

You define an entry in Administration>Platfom>Options node.

Then in your workflow, with Javascript activity you set:

setOption ("myValueToKeep", vars.NumErrors)

and getOption for reading the value kept between 2 executions, to initialize the vars.numErrors at the beginning of workflow.

xtk:options lines allow text and numeric values, so it is universal method.
I didn't use xtk:Counters, perhaps it is useful but xtk:options is a global system working fine.

Regards

Jean-Serge

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

Buon giorno Salvatore,

Please use xtk:options for this kind of storage, out of the scope of instance.vars.

You define an entry in Administration>Platfom>Options node.

Then in your workflow, with Javascript activity you set:

setOption ("myValueToKeep", vars.NumErrors)

and getOption for reading the value kept between 2 executions, to initialize the vars.numErrors at the beginning of workflow.

xtk:options lines allow text and numeric values, so it is universal method.
I didn't use xtk:Counters, perhaps it is useful but xtk:options is a global system working fine.

Regards

Jean-Serge