activities
latest
false
UiPath logo, featuring letters U and I in white
Workflow Activities
Last updated Nov 18, 2024

Retry Scope

UiPath.Core.Activities.RetryScope

Description

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

This activity does not work as expected in the Main workflow of an Orchestration process.

Project compatibility

Windows - Legacy | Windows | Cross-platform

Windows - Legacy, Windows configuration

Designer panel
  • Action - Add activities to be re-executed in this section.
  • Condition - Add a condition activity in this section.

    For instance, to fail and retry gracefully when indicating a UI element, you can use the Modern UI Automation Check App State activity or it's Classic Element Exists counterpart as a condition and attempt again to open the application and find the UI element.

Properties panel
Common
  • DisplayName - The display name of the activity.
  • Continue On Error - 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.

Options

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

Cross-platform configuration

Designer panel
  • Action - Add activities to be re-executed in this section.
  • Condition - Add a condition activity in this section.

    For instance, to fail and retry gracefully when indicating a UI element, you can use the Modern UI Automation Check App State activity as a condition and attempt again to open the application and find the UI element.

Common
  • Continue On Error - 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.

Options

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

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.


  6. Add an If activity and as a condition enter Random <> 0. This means that you check if your variable is different than 0.
  7. 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.
  8. 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.



  9. To exit the loop, add an Element Exists activity in the Condition section of Retry Scope and indicate the Notepad window.

    If Modern activities are used, the Check App State activity can be used as a Condition in the Retry Scope.



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.

Was this page helpful?

Get The Help You Need
Learning RPA - Automation Courses
UiPath Community Forum
Uipath Logo White
Trust and Security
© 2005-2024 UiPath. All rights reserved.