Define clean-up procedures

In some cases, your Bot may throw unexpected errors. Typically, these stem from instabilities in your environment.

You can use clean-up procedures to increase the stability and resilience of your Bots. These clean-up procedures ensure that if anything unexpected happens, the Bot cleans up your environment.

Note that clean-ups don't fix the error. The Bot still fails at the Step in question. However, clean-up procedures reset the environment.

Clean-ups consist of Steps that you define. If a Step in the regular Bot flow fails, the Bot executes the clean-up Steps at the end of the run.

By default, the Bot stops running after it has successfully completed a clean-up procedure. You can specify that the Bot should try to run again.

Clean-up vs. regular Bot flow

Use clean-up procedures only for unexpected errors. Clean-ups increase the stability of your Bots, but can't compensate for vulnerable Bot design.

Let's say that your Bot transfers customer information from a file to a web application. The web application does not allow double entries. If a person with the same first name, last name, and email address already exists in the database, the application triggers a pop-up dialog.

Handling this situation should be part of the "regular" Bot flow, not part of a clean-up procedure.

In this scenario, a clean-up might include Steps the Bot should take if the web application suddenly isn't available. For instance: save and close the file, close the browser.

Add a clean-up procedure to your Bot

To add a clean-up to your Bot, follow the steps below:

  1. Select a Bot.

  2. In the Flowchart tab, click on Add.

  3. In the Exception tab, click Create Exception Handlers. This adds the Exception Handlers element to your Bot.

    The Bot also automatically adds configuration parameters:

    • OnDialogFailure: triggers the clean-up in case of failed interactions. For instance if the Bot can't access a particular menu.

    • OnExceptionFailure: triggers the clean-up in case of unforeseen environment events that keep the Bot from running all Steps.

    • OnVerificationFailure: triggers the clean-up in case of unexpected content in your application. For instance if a cell contains a different value than expected.

    • BotRetries: defines how often the Bot should try again. You can specify how many times a Bot should restart from scratch after the clean-up procedure.
    • BotStepRetries: defines how often the Bot Step should try again. You can specify how many times RPA Studio should retry a Bot Step after the clean-up procedure.

    If you don't want to trigger clean-up procedures for a particular type of error, right-click the respective configuration parameter and select Reset to default value from the context menu. This deletes the configuration parameter.

  4. Determine what the Bot should do if a Step fails, i.e. add your clean-up Steps.

    To add clean-up Steps, click on Add in Exception Handler.

Add clean-up Steps

  1. Fill out the Step Values as you would for any Step.

  2. By default, the Bot stops running after it has successfully completed a clean-up procedure. You can specify that you want the Bot to try again.

    To do so, click on in the After Handling Step. In the subsequent dialog box, select Restart the Bot and select one of the following options in the subsequent dialog box:

    • Restart the Bot: the Bot starts again from scratch.

    • Restart from failed Step: the Bot tries again from the failed Step onward.

If you created a Bot Step from a Module whose property InterfaceType is NonGUI, and this Step fails, you can only recover on the Bot level.

Restart from failed Step is not available for NonGUI Steps.

Select an After Handling procedure

  1. Define how often the Bot should try again. To do so, specify BotRetries and BotStepRetries in the Max restarts field of After Handling Step.

    Note that the Bot doesn't execute the clean-up scenario in the last iteration.

    Let's say you have defined 3 retries. This means that if the Bot fails every time, it will run 4 times in total: the initial run and then 3 retries.

    In the first 3 times, the Bot also executes the clean-up scenario. If the Bot fails again in the 4th iteration, it doesn't execute the clean-up scenario.

You can only add one set of clean-up procedures to your Bot, i.e. one Exception Handlers element with one Exception Handler.

Modify or delete clean-ups

You can modify or delete the Steps within an Exception Handler at any time.

You can change their order via drag and drop. Additionally, you can add a Logic element as a Step within your Exception Handler.

You can turn the Placeholder within your Exception Handler into a regular Step.

To do so, follow the steps below:

  1. Click on Add within a Placeholder in your Exception Handler.

Click Add within a Placeholder

  1. In the subsequent dialog, select a Module, Logic element, or a Scan tab to replace your Placeholder.

To remove the defined clean-up from your Bot altogether, select the Exception Handlers element and press DEL.

This example shows a simple clean-up procedure for a Bot. Let's say you have designed a Bot called Example Bot:

Basic Bot flow

  • The first Step is actually another Bot called Get data. The Get data Bot accesses an application and saves various data to Buffers.

  • In the succeeding Steps, the Bot opens a web application, enters some of the data, and then closes the browser.

The Get Data Bot is completely self-contained and has its own clean-up. So you only need to think of a clean-up for the other Steps in the Example Bot.

If one of these Steps fails, the Bot needs to make sure to close the browser tab. This resets the environment.

Additionally, you want the Bot to send an email notification to the department that is responsible for this particular Bot.

This results in the following Exception Handler:

Possible clean-up procedure for Example Bot

You create these Steps from Modules in the RPA subset (see chapters "Create Steps from Modules" and "The RPA subset").

  1. Create the Step Close web application from the Module CloseBrowser.

    Use wildcards to ensure that you cover several browser tab captions.

Close the browser tab

  1. Create the Step Mail server connection from the Module Connect to Mail Server.

    In this Step, you specify the following actions for your Bot:

    • The connection you define in this Step has the name ExampleConnection.

    • Connect to the mail server named mailengine.examplecompany.com with the user name admin@mailengine.examplecompany.com and the respective password.

    • Connect via port 123.

    • Use a secure connection with SSL/TLS certificates.

    • Employ POP3 protocol.

Establish the connection to the mail server

  1. Create the Step Email the department from the Module Send Mail.

    In this Step, you specify the following actions for your Bot:

    • Use the connection ExampleConnection.

    • Use admin@examplecompany.com as the sender of the message.

    • Enter the message subject Bot "Visitor Data" was unsuccessful.

      Since your subject line contains the special character ", you need to escape it as shown in the screenshot below. For more information on how to work with special characters, see "Use special characters".

    • Send the mail to departmentXYZ@examplecompany.com.

    • Put admin.bob@examplecompany.com in Cc.

    • Enter the message body Your Bot was unsuccessful in the most recent run. Please check the result in the RPA Cockpit and contact Admin Bob.

Specify the email message

If the Bot encounters an error at run-time, it closes the browser and sends the email you have specified via the connection you have specified.

View results

If a Step in your Bot fails, the Bot executes the clean-up procedure at the end of the Bot run.

It executes the Steps in your Exception Handler in sequence, from top to bottom.

When you test your Bot, the Exception icon next to the Bot name in the Results tab indicates that a Step triggered the clean-up.

If you have specified Bot retries, you can view the result of each try. To do so, use the arrows to scroll through Bot runs.

If you run your Bot by clicking Run from here or Run selected, the Bot stops after performing the Steps in the Exception Handler. It does not run again, even if you have specified Restart the Bot.

Scroll through Bot test runs

Was this information helpful?

Tricentis RPA Studio Manual 2020.2 © Tricentis GmbH