Retries the contained activities as long as the condition is not met or an error is thrown.
- NumberOfRetries - The number of times that the sequence is to be retried.
- RetryInterval - Specifies the amount of time (in seconds) between each retry.
- 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.
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.
- Private - If selected, the values of variables and arguments are no longer logged at Verbose level.
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.
- Create a new sequence and add the Retry Scope activity.
- 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.
- In the Action section, add an Assign activity.
- Create a GenericValue variable, named for example Random and add it to the To field of the Assign activity.
- Add the
Now.Millisecond mod 5value to the variable by adding it to the Value field of the Assign activity.
- Add an If activity and as a condition enter
Random <> 0. This means that you check if your variable is different than 0.
- 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.
- 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.
- 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.
Updated 6 months ago