A good project or workflow should have the three things in a column: Good Exception Handling, should Scale at-need and Easy to Debug. Here’s a minimal Checklist of 5 to ensure that your Project satisfies the three important things.
Modularize workflows for Better Understanding, reusability & Scalability#
A process should have two layers which are Grouped Process and Splitted Process. A big process should be grouped as separate workflows (Ex: Logging into a web application and Scraping a set of data should be one workflow) and that grouped workflow should have reusable components (workflows) where each workflow should do only one thing and should have generic dependencies so that it can be reused at any point. For Example, The Grouped Workflow can be split into 3:
- Scrape Data
Exception Handling for both Known and Unknown Exceptions#
A process should handle all the possible known exceptions and unknown exceptions. First of all, what is known and unknown exception? Known exceptions are things that you can predict and check for before executing it and unknown exceptions are unpredictable. Known exceptions include checking if a file exists before moving or copying to another location to avoid File Not found Exceptions thrown at runtime and check if the page is navigated correctly to do operations on it to avoid possible Selector Not found Exception thrown at runtime, etc.,
Now, How to handle unknown exceptions? Just surround the workflow with a Try-Catch Block, then catch handles appropriate exceptions that might occur.
Logs are very helpful during the process and also for post-development. Logs tell what and when an exception occurred, what happened and happening in the process. UiPath can give generic logs but you need to ask UiPath to tell the process-specific log based on the business use case. Here’s a checklist for logs in your process:
- Logs at Start and End of a Workflow to know the successful execution of the workflow.
- Checkpoints - Logs at certain points in a workflow to know where your process execution is at.
- Decisions - Log Decision Making (Then & Else in If) to know what decision your process took.
Why do you want to name an activity? So, when an exception occurs, UiPath tells you where the exceptions occurred, it also gives information about the title of the activity. So if the activities are not named properly, UiPath will tell that an exception occurred, say ‘Click’ and there can be numerous Clicks. So if you name it like ‘Click Dashboard’, there are not many dashboards to click so it is easier to pinpoint the location of the exception.
Sequence, Flowchart & State Machine - Choose Wisely#
How to choose a workflow type? Sequence, Flowchart, and State Machine have their own use cases. For Example, a Login workflow can be a sequence since there won’t be a lot of decision making but what if there is a lot of decision making to be taken and where there are multiple branching logical operations, that’s where Flowchart can be handy.
So when to use a State Machine? Consider the following, your target application pops up a random TLS error and you need to retry that particular process. You can solve this with the help of a State Machine. A state machine can have a finite number of states to which you can transition to based on an outcome of a particular state. The first state will have the workflow where the exception occurs, It’ll have two transitions: A Retry State and A Final State. When Exception Occurs, Set the Retry Flag to True so that
it will transition to Retry State where it clears the session and retries the process. If there is no error/ maxed the retry threshold, it transitions to the Final State where it sends an email about the issue or does nothing if the process is successful.
Happy Automation! :D