How to keep the value of global variable defined in a wkf after it ends | Community
Skip to main content
salvdangelo
Level 5
December 18, 2017
Solved

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

  • December 18, 2017
  • 1 reply
  • 2137 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Jean-Serge_Biro

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

1 reply

Jean-Serge_Biro
Jean-Serge_BiroAccepted solution
Level 10
December 18, 2017

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