A2019 Read Config Values

 RPA | A2019 Read Config File Values| Automation Anywhere - Part-30


A2019 Read Config File values - Today in this article we will discuss about how to read configuration file values in A2019 Automation Anywhere. 

Whenever we are assigned a process for development the most crucial aspect while developing a process is to store hard coded values or information in the config file so that it can be used throughout the process development so if there is any changes in the information can be changed at one place instead of changing it across various modules developed in the process. So there are various ways in which we can read configuration file values using A2019 Automation Anywhere. So in this article we will see two approaches through which we can read the values which are as follows:-

  • Excel based approach.
  • XML based approach.
Now firstly we will see Excel based approach to read configuration file values. So whenever we create any process the common parameters that are used throughout any process are the path, URL, Processed Path, Output Path etc.

So the steps that are required to follow while using Excel based approach are as follows:-

  • Manually open the excel file. Create the necessary parameters such as folder path, URL, Processed path, Output path etc.
  • Open the A2019 Automation Anywhere.
  • Go to Bots->My Bots then click on create bot and give the bot name and click on create and edit.
  • From the Actions tab, select the CSV/TXT package then select the open command and in the properties section give the session name, then browse the file from the required folder location and then check the sheet contains a header checkbox and select comma delimiter in the delimiter option and UTF-8 as the Encoding option.
  • Drag and drop the Read command and in the properties section give the same session name as passed in the open command and store the output in the table variable data type.
  • Now loop through all the rows of the table variable and check if the row contains the key. If key exists then assign the output to a string variable data type and so on for all the required variables that we created in the csv files.
  • Once this is done drag and drop the close command of CSV/TXT package action and pass in the session name that we passed initially which will be used to close the csv file opened during the process creation.
Now we will see the code snippet for this approach as given below:-



The next approach that we will see to fetch values from the configuration files is the XML based approach. The steps that we need to follow in the XML based approach are as follows:-

  • First of all start the xml session by dragging and dropping start session under the A2019 xml package.
  • Then drag and drop the execute xpath function to access the values. For example, to access folder path the xpath expression that would be written is as given below: /config/environment[@id='EnvDev']/FolderPath
  • Then repeat the same command to access or to fetch other values from the config file.
  • Lastly, end the xml session by dragging and dropping the End Session action by passing in the same session name passed in the start session of the xml package.
Here is the snapshot of the xml file that looks something like this as given below.



Here is the code snippet for xml based approach as given below.






So that's all about this article where we discussed how we can fetch the values from the configuration file using A2019 Automation Anywhere. If you have any queries while going through this article then you can raise your queries in the comment section and I will be more than happy to answer your queries.

Comments

Post a Comment

If you have any doubts, please letme know.