Config file - how does it work

I have been trying to figure out how the config file works. I have downloaded the REFramework and tried going through it step by step, but I am not wiser.

If I decide to create a blank project, and would like to create a config file, how do I do that? I get that you create an excel sheet, and use Read Range to get the data. This is added to a dictionary, but how and when are the data in the dictionary added to variables?

Could someone describe the process step by step?

1 Like

Let’s talk about the ReFramework first. The ReFramework uses - indeed as you mentioned - a dictionary to store the configuration values. This happens in the initialization state

Looking closer at the initialization state - there is an if condition to determine whether the Config has been initialized already. If not, it will proceed running the InitAllSettings.xaml workflow. Since there has been no default value set for the Config variable, this will evaluate to True the first time the process is ran.

InitAllSettings.xaml will initialize the Config variable using the new keyword:

afbeelding

When doing so, the expression Config is Nothing evaluates to False. Even if the Dictionary is empty, it does not evaluate to Nothing since its now a Dictionary object. You -might- wonder: Why do we check if Config is set before reading the configuration file? We’re checking if Config is set before its set!. This is because in the ReFramework - and it is also best practice to do so - when an Application Exception (aka System Exception) occurs the initialization state is triggered again. This will close all applications to then re-initialize all applications (open, login, etc.) but the If condition prevents re-reading the configuration file.

In InitAllSettings.xaml the configuration file is read across several excel sheets within it. It loads all of these values into a Dictionary where the keys are of type String and the values are of type Object. This is because the Excel cells can be of different types - for instance String, Int, and so forth. It will also fetch all Orchestrator assets that you specify in the Assets worksheet of the configuration file.

Ok so lets say you would like to create your own configuration file. It is really as simple as:

  1. Read Range to get a DataTable filled with your configuration data
  2. For each the DataTable
  3. Use the Assign activity to put it into the Dictionary.
  4. You can now use your dictionary to get the configuration file. For example Config("Username").ToString

18 Likes

Thanks for the long and detailed response. I will run some tests and see if I can get it to work - thanks again :slight_smile:

thanks!

Hi @OpalSnow I am using studio with the similar framework. The bot is not reading the config file on the sheet name which is mention on the read range. It throws an error mentioning the file is not in config file. I try to debug and run with log info. It reads correctly. Is there anything i miss out?