Working with a Config file in Automation Anywhere A360


Setting up a Config file is a quick and easy approach to set up the automation environment’s basic settings. Rather than modifying the code, it is simple to adjust settings in the Config file. The ability to adjust the values at each run is provided via the Config file.

What is Config file?

Configuration files (commonly known simply as config files) are files used to configure the parameters and initial settings for some computer programs. They are used for user applications, server processes, and operating system settings. In Automation, the Config file contains the URLs, Credentials, important settings.

Why Config file is needed?

Setting up a config file is an efficient way to configure the initial settings of the automation environment. Variables that refer to path locations, URLs, and other config information that you need to set up when moving your workflow from one environment to another are better placed inside a config file. Config files can be of type Excel(.xlsx), CSV(.csv), XML(.xml), Text(.txt), etc.

The code change is costly – It is easy to update values in the config file rather than changing the code. Config file gives us the flexibility to update the values at each run. We can store environment level values as well for e.g., a set of values for Dev environment & values for Prod environment.

Here’s a step-by-step guide on how to work with configuration files in Automation Anywhere:

Text file as Config

To achieve this, we have to use CSV/TXT package. Each line for text file will be read. Using delimiter, key and value needs to be extracted.

Sample txt config file:

config_str_key1=value1

config_str_key2=value2

config_str_key3=value3

config_str_key4=value4

config_str_key5=value5

image 204

Excel file as Config

Mostly commonly used config file type is Excel. Excel config file can contain multiple sheets, each sheet to group respective parameter values. It can be environment specific values; it means each sheet will have values for respective environment. Sheet1 can be used for Dev environment, sheet2 can be used for Prod environment, etc.

Excel config sheet has 2 columns, one stores the Key name and another to store the values for respective key and then key-value pair is stored in dictionary variable for further use in code.

Sample Excel config file:

image 205
image 206

XML file as config

This can be achieved by using XML package. Using XML function, we can get the value for each element.

For example, to access folder path the xpath expression that would be written is as given below: /config/environment[@id=’Dev’]/FolderPath

Sample XML file:

<?xml version=”1.0″?>

<config>

               <environment id=”Dev”>

                              <FolderPath>C:\Users\Lenovo\OneDrive\Desktop\MyFiles</FolderPath>

                              <URL>https://community.cloud.automationanywhere.digital/</URL>

               </environment>

</config>

image 207

Tips for Effective Configuration Management

Use Environment Variables
For sensitive information like passwords, use environment variables instead of storing them in plain text files.

Version Control
Keep your configuration files under version control to track changes and ensure consistency.

Error Handling
Implement error handling to manage cases where the configuration file might be missing or contains invalid data.

By using configuration files, you can make your Automation Anywhere bots more adaptable and easier to manage.

Happy Automation!                                                                        

Categorized in: