UiPath Activities Guide

Retry Scope

UiPath.Core.Activities.RetryScope

Retries the contained activities as long as the condition is not met or an error is thrown.

Properties

Options

  • NumberOfRetries - The number of times that the sequence is to be retried.
  • RetryInterval - Specifies the amount of time (in seconds) between each retry.

Common

  • DisplayName - The display name of the activity.
  • ContinueOnError - Specifies if the automation should continue even when the activity throws an error. This field only supports Boolean values (True, False). The default value is False. As a result, if the field is blank and an error is thrown, the execution of the project stops. If the value is set to True, the execution of the project continues regardless of any error.

Note:

If this activity is included in Try Catch and the value of the ContinueOnError property is True, no error is caught when the project is executed.

Misc

  • Private - If selected, the values of variables and arguments are no longer logged at Verbose level.

Example of Using the Retry Scope Activity

The Retry Scope activity is used for catching and handling an error, which is why it’s similar to the Try Catch one. The following workflow attempts to open the Notepad window 3 times and uses the condition set in the Retry Scope activity to stop the loop.

  1. Create a new sequence and add the Retry Scope activity.
  2. In the Properties panel, leave the default NumberOfRetries of 3 and the Retry Interval of 5. This means that we attempt to open the Notepad window 3 times and the interval between tries is 5 seconds.
  3. In the Action section, add an Assign activity.
  4. Create a GenericValue variable, named for example Random and add it to the To field of the Assign activity.
  5. Add the Now.Millisecond mod 5 value to the variable by adding it to the Value field of the Assign activity.
  1. Add an If activity and as a condition enter Random <> 0. This means that you check if your variable is different than 0.
  2. In the Then section of the activity (the condition above is true):
    • Add a Message box stating “Notepad Window failed to start”.
    • Under the Message Box, add a Throw activity to throw an error.
    • Type in New System.Exception(“Notepad failed to start”) in the Exception field, under Properties.
  3. In the Else section of the If activity (the condition above is false):
    • Add an Open Application activity and indicate Notepad on the screen. Provide the full path of the Notepad executable file in the FileName field part of Properties.
  1. To exit the loop, add an Element Exists activity in the Condition section of Retry Scope and indicate the Notepad window.

This workflow simulates a failing Notepad window. If the value of the Random variable is different than 0 three times in a row, the “Notepad Window failed to start” message is displayed every time and the entire workflow fails with the “Notepad failed to start” error. The latter message is the one added in the Throw activity.

If the value of the Random variable is 0, the Robot opens Notepad and because the exist condition of this loop is to find the Notepad window, the workflow is successfully completed.
 
 
Download example


Retry Scope


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.