How to jump to another activity when have some error?

Hi all, I want to jump to another activity when have some error for example: I’ve activity A,B,C,D… How to jump to D(skip B and C) when A have some error? Please help me to do this idea.

Thanks.

@jnfantasy4

Have each sequence or step separate…

And after the sequence complete check if there are any errors for this you can surround the whole step with try catch in catch block set error variable to true…so if variable is true go to stepD else go to step B here you can use flow chart and call each sequence and check for conditions

Cheers

1 Like

@jnfantasy4,

If your activities are bigger logics you can put them in separate workflows and invoke them in Flowchart type of workflow.

In Flow Decision you can check if the earlier sequence failed or not and accordingly add arrow to next steps.

Thanks,
Ashok :slight_smile:

1 Like

@jnfantasy4

In UiPath, handling errors and controlling the workflow based on specific conditions is straightforward using activities like Try Catch and Throw, along with the appropriate flow control activities. Here’s how you can achieve the desired behavior of jumping from Activity A directly to Activity D when an error occurs:

  1. Use a Try Catch block: Wrap Activity A in a Try Catch block to handle any errors that occur during its execution.
  2. Throw an Exception: If an error occurs in Activity A, throw an exception to indicate the need to skip to Activity D.
  3. Use a Flowchart or State Machine: Design your workflow using a Flowchart or a State Machine to control the flow based on exceptions or specific conditions.

Step-by-Step Implementation:

1. Create a Flowchart

  • Create a new Flowchart in UiPath.

2. Add Activities to the Flowchart

  • Drag and drop the activities A, B, C, and D onto the Flowchart.

3. Wrap Activity A in a Try Catch

  • Inside the Flowchart, wrap Activity A in a Try Catch activity.

4. Configure the Try Catch

  • In the Try block, place Activity A.
  • In the Catch block, handle the specific exception you expect (e.g., System.Exception). Inside the Catch block, use a Throw activity to throw a new custom exception (e.g., new BusinessRuleException(“Error in Activity A”)).

5. Add a Decision Activity

  • After the Try Catch block, add a Decision activity to check if the custom exception was thrown.
  • You can use a Boolean variable (e.g., isErrorOccurred) to track whether an error occurred. Set this variable to True inside the Catch block of Activity A.

6. Configure the Decision Activity

  • In the Decision activity, check the value of isErrorOccurred.
  • If isErrorOccurred is True, direct the flow to Activity D.
  • If isErrorOccurred is False, direct the flow to Activity B.

7. Connect Activities Based on the Decision

  • Connect the Decision activity to Activity D if isErrorOccurred is True.
  • Connect the Decision activity to Activity B if isErrorOccurred is False.
1 Like

Hi, Glad to see that you are a part of the automation journey with UiPath.
To answer your query, below methods can be tried:
a) You can make use of conditional blocks to handle such situations. In your case, for A, B, C & D scenarios, create separate workflows. In the main workflow you can call these sub flows. For eg: If there is an error in scenario A, then call the D workflow in then part.

b) You can make use of Try Catch Block. The logic you write in Try throws an error then you can trigger the required actions you want to perform in the Catch block.

c) Throw an exception. You can use the Throw activity to do this and it will skip the steps you want and directly execute the D block in your case.

Hope the above solutions help you to proceed ahead.

Thanks,
Shruti Basutkar

1 Like