By Kayla Cullen
The demand for robotic process automation (RPA) is astonishing and, in turn, the demand for RPA developers to develop automations quicker and with fewer flaws is greater than ever before. In the constant quest for maximizing the benefits of automation, companies often turn to RPA developers to implement new functionality.
The following is a list of six tips and tricks that can help RPA developers working with the UiPath automation platform develop automations faster, increase their reliability and readability, and implement new functionality.
Use the automatic recording tool
UiPath offers a recording tool in its coding platform Studio. The recorder automatically records the actions you perform on your screen and then outputs a workflow for the process you just completed. With the proper activities already generated, this output workflow is a great starting point for developing your automation. It provides a framework that you can then modify and build on. For example, you can change the parameters of the activities, modify the selectors, add hotkeys to the type into fields, and add additional activities to the workflow. It is important to recognize that the recorder will not generate fully functional automation but will rather reduce coding time and provide a standardized sequence template that must be updated to account for the automation’s business logic.
Use generic selectors
To automate precise actions in an application’s user interface, you must click and interact with many different windows, text fields, buttons, drop-down lists, and other elements. UiPath’s Studio uses selectors to store the graphical user interface elements and its parent elements as an XML fragment. The selector of each activity acts as a map to point the bot to the correct element on the screen. Studio’s user interface activities automatically generate the selectors for you. In most cases, the attributes within the selectors are too specific and may cause an automation to fail. For example, if the value of an attribute changes each time an application is started, then the selector will not be able to accurately distinguish the element with which the bot is trying to interact. To combat this, it is best to modify the selectors and make them as generic as possible by using wildcards. It is important to pick attributes with a constant value.
Use an inline "if statement" to assign a variable
Developers use an “if statement” to automate decisions based on the value of variables. Studio offers an “if” activity that consists of a true or false statement and two conditions. The “then” conditional is executed if the statement is true, and the “else” conditional is executed if the statement is false. The “if” activity is effective when the bot must execute a sequence of activities depending on the case, but an “if” activity should not be used when assigning a value to a single variable. Instead, use an inline “if” statement. This will cut down on the clutter in your workflow and make your code easier to read. The inline “if” statement is composed of a single-assign activity that contains the variable in question along with a visual basic (VB) “if” statement that will determine the variable’s value. Here is an example of how to use an inline “if” statement where that variable “greaterValue” is a Boolean and the variables “var1” and “var2” are integers:
greaterValue = If(var1 > var2, True, False)
In the above example, if “var1” is greater than “var2,” then the variable “greaterValue” is assigned “True.” Otherwise, it is assigned “False.”
LINQ stands for Language-Integrated Query and enables you to query data in a simple and powerful way. In UiPath, LINQ is commonly used to query arrays, data tables, dictionaries, lists, and XML. Arrays, dictionaries, and lists require no modifications or special treatment to act as a LINQ data source. XML and data tables do not execute as “IEnumerable<T>,” so a LINQ provider must be applied to use LINQ. For example, say you must filter a data table by extracting the records where the column “State” equals “PA” or “NJ” and the column “Phone Number” contains a value. The LINQ query would look like this:
outputDT = inputDT.asEnumerable.Where(Function(x) x(“State”).toString <> Nothing and (x(“State”).toString = “PA” or x(“State”).toString = “NJ”)).CopyToDataTable()
Notice in the above example, we must convert the source data table “inputDT” into an “Enumerable” to use the LINQ query. We must also add the “CopyToDataTable()” statement to output the data to the data table “outputDT.” Using a LINQ query can save you from using multiple activities to achieve the same result.
UiPath Connect contains a marketplace of pre-built reusable RPA components. The marketplace is a great place to look for components like custom activities, workflow templates, machine learning models, and solutions that can help save you valuable coding time. Getting started is quick and easy. You can download components from the marketplace and add them to your package feed, or you can download them directly from the Studio feed. The component’s details page contains documentation, user guides, and videos that can help you get the component up and running. The marketplace contains custom activities that interact with many popular applications such as, Salesforce, SharePoint, Excel, Outlook, Microsoft Teams, SAP, and many more. There are even custom activities that zip/unzip files, compare data tables, and help you manage file downloads. Be sure to check the marketplace before developing a new automation since new content is constantly being adding.
Some websites and web applications update often, and, no matter how generic you make the selectors, the bot still may not be able to find them. To prevent this, developers should use web service calls whenever possible. For example, say the bot must download a report from the web application Workday. Instead of having the bot navigate through the user interface of Workday, the bot can use a web service call, such as an HTTP Request, to extract the contents of the report instead. UiPath has prebuilt activities for both HTTP Request and SOAP Request web service calls. Both activities have a design wizard that provides an easy way to build the request and preview the server response. Using web service calls will help make your automations more stable and dependable.
CAI helps enterprises prepare for and implement RPA so that it achieves business goals, saves costs, and frees human workers from repetitive work. Contact us to find out how we can help your organization use automation to improve productivity and accuracy.