Best place to put soft-coded configuration variables

New to UIPath and noticed that my current design pattern has many items that can be soft-coded and simply changed from process to process. For example, we have an email address we send to the user(s) when things are completed. So I would like to soft-code this so I can always just point to where this is stored and use the value there. Even if we need to change who gets these emails in the future we could just change the value and not touch the coding.

So far the only place where I see this can be done is in the config excel file. Is that the best place to do this?

2 Likes

Hi @Bryan_Schmiedeler,

Yes, configuration file is an option. Usually, an excel, xml or a json file.

Another option is work with Orchestrator Assets.

The four Assets types: Credential, Int, String and Boolean.

Particularly, I use both config file and Assets in a project.

In some cases, usually when I am working with credentials, I refer asset’s name in the config file. So, first I get asset’s name from the configuration file and then, I inform it to get its value from Orchestrator through Get Asset / Get Credential activity.

When is something more related to configuration, such as folder path, file path, url, etc., I use config file.

When is something more related to business rule, such as recipients of an email, limit of rows that a file must have, etc., I use Assets.

If you are working with credentials, choose Windows Credential Manager or Orchestrator Assets (credental type).

Also, Orchestrator Assets have a feature where you can set different values per Robot. So if you have this need, use them.

Moreover, one single Asset can be used in more than one automation process.

You can learn more about Assets in UiPath Academy RPA Developer Foundation course. There is a lesson that explains them (Orchestrator for Developers).

3 Likes

Gustavo this is a very informative article which I appreciate. We use the config file and I now understand that it is really pretty easy to access this dictionary object anywhere in the workflow. We also do use some assets.

I only have 2 outstanding issues.

First, we will process x queue items. During processing we want to keep track of the unique id for the item (like Ticket Number), if it was successful or not, and if not what the error message is. We have an email address (or addresses) in the config file about who gets this email.

Currently these items are stored in a data table, which we have to pass around as arguments. This is OK but not great really. I looked to see if I could store it in the config file object once I have it in memory, but it is a dictionary and I cannot. Is there any other better way.

Second, we have several config values that come in twos in that they will be one thing in dev and the other in test. So we change them in the config file when we go to development. Would be a little easier if we could just store a value in the config file for environment (dev or prod) and the config process would load the correct values. I would like to not have to code this so that when I want to use a config variable I have to check if we are in dev or prod and then pick the value, nicer if it loaded up the correct value right in the config module. But I cannot figure out how to do this.

If there is some best practice about how to do this I would appreciate knowing it.

1 Like

Hi @Bryan_Schmiedeler,

Glad it helped you :slight_smile:

About your second comment…

I suggest you create an input argument in your main workflow, it is usually Main.xaml. Unless, you have renamed it or created another workflow and set it as the main one.

Just be aware that this solution opens a gap to execute the process with the production values. So, Orchestrator permissions must be extremely suitable for users.

How would it work using excel file?

  1. In this scenario, you could have two settings sheets in your Config.xlsx. Named, for example, Settings_PROD and Settings_DEV. Each file with the correct values, according to the environment.

  2. Create your input argument in your main file. You could name it as in_Environment, for example. This argument will be a String.

  3. Now, when you read the configuration file, you will consider the value of this argument when informing the “Sheet” field of the Read Range activity Example: 'Settings_'+ in_Environment.
    If you are using REFramework, in the invoke code of the InitAllSettings workflow, change the in_ConfigSheets argument from {"Settings", "Constants", "Assets"} to {"Settings_" + in_Environment, "Constants", "Assets"}

  4. Finally, when you create your job or schedule in Orchestrator, enter the value of the argument in Parameters tab. Check image below:

image

This way, if you want to change environments, you just need to change the parameter. Thus, it avoids changing values directly in the configuration file every time you need to change the environment.

Probably, when you are working on your local machine, I mean before your project goes to DEV and PROD environment… You don’t want to run through Orchestrator to save some time, so just use an assign activity to set in_Environment value or use Default value. Then, delete it before uploading the project to Orchestrator.

How would it work using json file?

Same ideia and your json would look something like this:

{
  “DEV”:
  {
    “url”: “https://www.dev.forum.uipath.com”
  },
  “PROD”:
  {
    “url”: “https://www.forum.uipath.com”
  }
 }

Then, to read values you would use jsonConfigVar(in_Environment)(“URL”).toString, for example.

That’s it…

If it helps you, please let me know.

About your first comment, @Bryan_Schmiedeler…

How are you working with this queue? Are you using REFramework and Orchestrator queues?

About storing in the config file, it wouldn’t be a good practice, because this is not the purpose of the configuration dictionary.

Could you explain your process? I need to understand it better to share some idea.

Thanks

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