Creating variables if needed during execution


I have a process running for multiple clients.
Each clients have different number of inputs.

Instead of creating all needed variables for all clients beforehand.
Is there a way to create needed variables during execution time ?

Small example:
Client A need variables X and Y.
Client B need variables X, Y and Z.

They both use var X and Y, but only client B use var Z.
So the usecase is:
Instead of creating X, Y and Z in Studio, create only X and Y, and create Z during exectution time if process is running for client B.

Hi @Hawkman

We can’t able to create the variable during the execution time.


Hello @Hawkman

As far i know ,Creating the variable during execution is quite impossible


Hello @Hawkman

We cannot create variables during execution.But here if the number of input is changing maybe you can get all the entries to a list and then use that list variable to action.


we cannot bypass compiling so we have to define the variables before.

But witch selecting an appropriate datatype e.g. Dictionaries or approaches like datatables, JSON we can achieve such a flexibility

So I disagree with the “can not” approach, but I do agree that dictionaries are likely a better option.

Of course, creating additional variables during the process is a complex feature that has debatable purposes, but you can edit an xaml file before opening it if you invoke the workflow after editing it. The basic, high-level steps are:

  1. Use a Read Text File activity with the xaml where you want to use the additional variables and save it into a string, “str_CurrentXAML” (note, the xaml can NOT be in use yet! So don’t try this with your main.xaml)
  2. Use string manipulation to insert the additional variables into the xaml with an assign activity and save to “str_AdjustedXAML”
  3. Use Write Text File to write str_UpdatedXAML to the xaml file
  4. Invoke the xaml file and the new variable will be in place.
  5. Use Write Text File activity to write str_CurrentXAML back to the xaml file. It will now be in its original format.
  6. Run it once (in unattended mode) and it will fail, because it can’t read or write the file yet because of permissions issues.
  7. When used in unattended mode, go on the computer object where the unattended Robot account is going to execute it and find the path where your to-be-edited xaml file exists. (%userprofile%.nuget\Packages\package name\version number\lib\net45)
  8. Taken ownership (requires admin rights) and allow your robot account to modify the file.

There are some MAJOR drawbacks to this:

  • anytime you create a new package version, you’ll have to re-take ownership and grant permissions to modify the file. If you run a larger number of bots (and especially with modern templates,) you’re looking at a good number of manual edits, which approaches a defeat of the purpose of automation.
  • the data you are editing needs to make sense to be used in your process, so again, most likely a dictionary is a more valid setup to use than just adding variables.

I want to emphasize: impossible? nope! useful and a good idea… maybe not so much. Best practice? really nope.

Hi devroen

Thank you for the elaborating answer. This looks like the best solution for my original question.
I agree that it’s not best practice at all, and might do more headache than pleasure.

I guess creating all the needed variables (if the amount is small) beforehand is best. Otherwise using dictionaries is the better choice.

I’ll mark your answer as solution, as it provided a direct solution to my question :slight_smile:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.