Global Variables that can be used across Workflows and Invoke Workflows

Is there a way to define global variables like static variables or constants that we do in programs which can be used across multiple workflows and invoke workflows, instead of duplicate and passing the value as arguments to every call of an invoke workflow.

Can you think of any other scenario where these might be useful? In the absence of these, why not use Orchestrator assets?

2 Likes

Config is the obvious one. A lot of companies use config excels due to it being easier to configure than assets for dev/test/prod. Technically speaking you could serialize your config to an asset, but that defeats the “easy to change” part (and not everything goes through serialize->deserialize nicely).
There’s also some use cases for FrontOffice/Attended robots, where users can modify their personal config (f.e. input and output folders, email accounts to use, etc.). Assets aren’t the best for that, even if technically possible to do and also that would introduce dependencies for the workflows (i.e. if a workflow uses GetAsset, to test it’s behaviour I need to change that assets value, instead of testing with argumented invokes, or introduce a middleman workflow in-between the true caller and true callee).

I’m not a big fan of globals, but since there is no other easy way of obtaining persistence of data between workflows (outside of passing it around everywhere), I wouldn’t be against it (we actually had a custom activity that added a pseudo Singleton for mapping tables in some processes, it did break on Isolated calls though due to lack of shared memory).

Because that’s an external dependency and is also much slower than memory access and has data security implications.

3 Likes

I second this. When splitting workflows into multiple xaml files, passing configuration values as parameters adds extra complexity. Using external dependencies to pass variables from one workflow to another also adds complexity to a process. Global variables would be useful.

There’s a good reason why it’s often frowned upon to overuse global variables because overuse could also add complexity to any program or process, but they are still an important tool in the developer’s toolbox

Perhaps UiPath can develop a similar flow as the Global Exception Handler, where we can define global variables :slight_smile: