Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

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

salvdangelo
Level 5
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
Jean-Serge_Biro
Correct answer by
Community Advisor
Community Advisor

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
Jean-Serge_Biro
Correct answer by
Community Advisor
Community Advisor

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