Global Variable

How to create global variable and use through the multiple workflows?

I’ve created dictionary(Of String, Object) and pass it across my xaml’s as In/Out argument.
This way I can access all dictionary entries across all my workflows and all edits to the values are also available.

3 Likes

Hello!

To use variables through workflows, you just have to pass it as arguments in “Invoke workflow file” Activity (Arguments property).

Hope It Helps!

Regards,

3 Likes

Ultimately you should be using Orchestrator which allows you to create assets and credentials which can be used throughout multiple processes. Of course this comes with price :smiley:

I have the same question.
If I want to use a variable in 50 workflows, it is a very tedious job to pass it argument to the next 49 workflows. Is there any way that I can use the global variable in all my workflows without passing it as argument?

2 Likes

Is there any other way? Like can this be done with flowcharts or state machines?

@bristighosal910 a good idea as an improve to usability for workflows could be to automatically assign as input variables when you import if you have them in the context with exactly the same type and name.

Anyways workflows are similar to functions and probably don’t even have to be part of the process itself since you can use them through multiple processes so… using global variables… its an option but not a best practice

Okay, Thank you.

You might consider to use Environment variables stored in the current process.
The are accessible through the Get Environment Variable activity or inline, like: Environment.GetEnvironmentVariable("Domain")

You can set them with an InvokeMethode activity, e.g:
image
SetEnvironment.xaml (7.1 KB)

Note: you can only globalize String type variables this way

5 Likes

https://forum.uipath.com/t/use-of-global-variable/29815

are all same, guys please vote one another (to bump this) as its a good feature

This is different from the “using argument passing for a global variable” because that is just passing around the variable copy which is exactly what this idea wants to avoid

6 Likes

You could define a custom .NET type, maybe a static class with public (static) fields and properties. This class could be initialized when your workflow starts, and the values are then accessible throughout all workflows via the static interface. This class might even be smart enough to initialize itself from the config file. Like any custom type, you would need to bring it into UIPath via the package manager.

Can there be a global variable which can be accessed across workflows in a project without passing as argument in workflows

Hello there,
It’s been proposed already. :slight_smile:
However you could do via dictionary or Orchestrator assets .

2 Likes

i am currently using assets or dictionary. but as a framework when i try to fetch all values initially it requires passing them as arguments across workflows. else i need to access asset in each workflow

1 Like

Hi,

you can use this component to set your variables globally. it follows the pattern declare once and use anywhere in the project. This component supports all data types supported by UIPath.

Thanks,
Manoj Batra

You can use the Velocistar Global Variables Activities now!

hi @mwerner i got problem of your global variable activities. the output of GetAll global variable type of “String” i cant set it to Dictionary<string, object>, could you fix it or tell me what i missed something, thank you

I don’t like the idea.

Global variables can be altered anywhere and makes difficult to tracking all the sequence of changes that you did in the variable. It can be anywhere in the code.

Another problem is that everyone will start to thinking: “If I can set a value here and get this value in anywhere why I should continue passing arguments to worfklow? I will just abandon that and use Global Variables for everything.”

Global variables brings more drawbacks than benefits.

Orchestrator Asset

Let’s ask the important question here. Why are you using multiple workflows? Is it really necessary? This seems to be very common with UiPath developers, but isn’t often necessary. UiPath likes to push their REFramework that does this, and it’s overkill and overcomplicated for most automations.

Why can’t your entire process just be built in one workflow?