The Retry Scope activity is not supported and does not work properly when used in the Main workflow of an Orchestration Process. In such cases, they should be placed inside a No Persist Scope activity. What if the code implements activities from UiPath.Persistence.Activities or Document Understanding, and placing them in a No Persist Scope isn't an option?
Issue Description:
The Retry Scope activity is not supported and does not work properly when used in the Main workflow of an Orchestration Process.
Typically, the recommendation would be to place inside a No Persist Scope activity.
However, if the code implements activities from UiPath.Persistence.Activities or Document Understanding, placing them in a No Persist Scope isn't an option.
Resolution:
Steps to Replace Retry Scope:
- Create a Boolean Variable:
- Name it completed.
- Set its initial value to false.
- Remove the RetryScope Activity:
- Delete the existing Retry Scope activity from your workflow.
- Use Try Catch Activity:
- Place the action sequence (the tasks you want to perform) inside a Try Catch activity.
- In the Try block, perform the persistent activity.
- If the activity is successful, set completed to true.
- In the Catch block, log the failure.
- Encapsulate in Do While Activity:
- Wrap the Try Catch activity inside a Do While activity.
- The condition for the Do While activity should be completed = false.
- This means the workflow will keep trying the action sequence until it completes successfully.
Considerations:
Performance: Ensure that the retry mechanism does not lead to excessive retries, which could impact performance. You might want to add a delay or a maximum retry count to avoid infinite loops.
Error Handling: Make sure that the errors are logged appropriately and that any critical failures are handled in a way that does not disrupt the overall workflow.