Global variables in workflow

I’m trying to use global variables in the workflow, I’m assuming these are necessary if I’m using subprocesses. I have two main processes that share the subprocess, and the two main processes are self-replicating.

But even though the global variable is being set each time in the subprocess in a task, it’s not doing something right, and its reusing the value from the previous document on the next one or two documents.

Am I doing something wrong with global variables?

Hello R,

Actually, global variables are pretty much the worst way to do this, for precisely the reason you uncovered: Global Variables are not instanced, meaning they are shared between all processes.

You can, however, use Job Infos, Local Variables, or Metadata for this task, as these are all passed to the subprocess when it runs in production.

~Evie

Evie has provided a better answer. I will struck this one down.

No, as Evie pointed out, resetting global variables from several processes simultaneously is pretty much a recipe for disaster. Global variables should - except in some very specific instances - be used in a write-once/read-many fashion: you set them in your startup process (or in a process that runs once a day, for instance), and you can use their values in other processes.

For passing information to sub-processes, local variables and jobinfos are definitely the way to go. If you still want to use global variables to drive those processes, then you should create a local variable and you should assign the value of the global variable to that local variable at the start of your process. Then, you can make any change you want to the local variable (and pass it on to sub-processes) without impacting any other process.