UiPath has come a long way in the recent years and they have been adding a wide variety of features and activities within UiPath Studio to help Automation processes and ease the development effort.
In this section, we will look into what the UiPath ReFramework is and the benefits of using this approach to standardize best practices when automating. This robust, consistent model will enable development standards, cleaner maintenance and potentially help organizations looking to embrace citizen development.
What is ReFramework?
Robotic Enterprise Framework (aka ReFramework) is a template within UiPath Studio built using State Machine layout. At a high level, it provides an excellent Exception Handling mechanism, retrying a failed transaction, application recovery and the ability to stop the process where continuing to run the Bot does more harm than good. ReFramework enables you to put the external settings in a Config.xlsx file and Orchestrator Assets instead of hard coding settings like a Shared Network Path location or Credentials within the script.
ReFramework is process independent. Any type of process can be built, tested and run irrespective of it being attended or unattended and regardless of the process data type and the applications you are automating. What Reframework provides you si simplicity and ease when automating with event logging for exceptions and logging around other relevant transaction information. It also sends those logs to Orchestrator for safe keeping. The logs can also be configured and sent to Elasticsearch, logstash or the Kibana platform for a more visual way of representing the data (which will be a different topic altogether that we will later cover on).
The key advantages to leveraging the ReFramework are highlighted below:
- Logging: Exceptional logging mechanism to monitor the process and error handling.
- Scalability: Ability to retry a failed transaction multiple times and send exception notifications.
- Consistency: Variables, assets and Orchestrator Settings are consistent across ReFramework and will be easy to understand and the code standards will allow for a more painless handover to a different developer.
- Reusability: Works for any type of processes and business logic code is separated from other aspects of Reframework like exception handling which enables it to be used across multiple processes.
- Error screenshots: ReFramework has the functionality to take a screenshot of the screen at the point where it failed, which useful in unattended automations and overall troubleshooting.
How it works?
If you have hands on experience working on UiPath Studio, you might be aware that UiPath Studio has 3 type of data flow representations: sequence, flowchart and state machine.
ReFramework contains all 3 of these data flows but the main structure of the program is built using state machine as it provides a cleaner and more desirable dataflow representation.
UiPath has the following components in the order in which they are called in the template:
- Initialize Process
- Get Transaction Data
- Process Transaction
- End Process
Since the system can only be in one state at a time, at least one transition condition from a given state must be true for it to move to another state. If it failed in any of these states, ReFramework is built in a way to either retry it or end the process and send an exception log with the reason.
We will now look into detail on each of the states and the purpose it serves
Initialize Process/Init State:
In this State, we are initializing all the settings and the applications required before the Bot starts working on the business end of the process. For example, if the Process we are trying to build is to upload an attachment in SAP, we first require the Bot to fetch the credentials from Orchestrator, open the SAP application and login to SAP using the credentials. UiPath ReFramework is built in a way so that one can initialize all the applications necessary here in the Init state and if the conditions we have built are met, the Bot will then move forward with processing the transaction.
If there is an error while initializing the applications or the credentials provided are invalid, an exception notification can be sent from within Init State and end the process.
Get Transaction Data:
Once the Bot has successfully initialized all the applications it requires for a process, it will then look if there are any transaction items in the Orchestrator Queue to process. The Bot will then process the items in the Queue one by one by monitoring the Queue. If there are no more Items to process the Bot is then going to end the process and close all the applications. We can also have the process look at a spreadsheet, databases, email or webAPI instead of a Orchestrator Queue depending upon the Business Requirements.
If a stop request is initiated while the Bot is in between processing a Transaction item, ReFramework has prebuilt functionality to look for a Stop Request and will stop the process even though there are items still in the Queue to process. This will be helpful if you notice the Bot is not doing what it is expected to do and want to stop the process before it works on any other transaction items.
Process Transaction State:
In this state, all process specific workflows are invoked. Going back to our example of attaching a document in SAP, the Bot has now initialized the SAP Application, got the Transaction Data from the Queue and the Bot should now upload the attachment to SAP. So, here in Process State, all the activities to attach the document are invoked. For example, a workflow to check if the document exists on the Shared Path, a workflow with activities like clicking on relevant GUI Elements for the Bot to navigate through SAP, type in the file path and look for an acknowledgment the document was successfully attached.
Once the Bot has finished processing a Transaction Item, it can either be a successful or a failed transaction. We would now want to see the status of each of the Transaction Items, this can be achieved by a prebuilt SetTransactionStatus workflow in ReFramework. With this, we can set a Transaction Status of an item to either Success, Business Exception or Application Exception. Business Exceptions are prebuilt exceptions that are built into the script and which the Bot should be looking for. For example, if the document the Bot is looking for is not in shared path, the Bot can set the status as business exception and notify the business team about the missing document. An Application Exception is when the Bot encountered an unknown exception, either due to the SAP application crashing or the Bot could not look for certain elements it is supposed to. Application Exceptions can be retried multiple times and the Bot will retry the same transaction item to see if it has a successful status on its second retry.
If the Bot processed the transaction successfully the Transaction Status can be set to success and the bot will now move forward with the next item in the Queue.
After the Bot has finished processing all the transaction items from the Queue, it will log out of applications and close them in this state. This is the final state of ReFramework and the applications are closed irrespective of if it is a failed or successful transaction.
ReFramework is scalable and robust in what it has to offer when getting started on an automation but there are also number of tweaks a developer can make specific to a process one is developing that can make ReFramework even more useful. For example, ReFramework is now built in a way to initialize the applications before it looks for the Items in the Queue. If you do not want the Bot to initialize the applications first and then later find out there are no transaction items in the Queue, one might not find it ideal to keep initializing and closing the applications on every scheduled run. Therefore few activities can be added to ReFramework that will enable the process to look if the Queue has any items first and only then start Initializing the applications which we currently do at Ashling Partners.
UiPath is continually adding new features and updates to UiPath Studio and ReFramework so keep an eye out on the latest news and updates!