Cleaner way to exit from ' Invoked work flow

I am looking for a cleaner way to exit from an invoked workflow. I Noticed a lot of suggestions about ‘Terminate workflow’ and Try/Catch block in the invoking code and suppress the exceptions etc.

But is there any cleaner way like in .NET C# - we can use a return statement from anywhere in the function/method and the control will be returned to the calling code.

Thanks

1 Like

i think the cleanest way without using try/catch or terminate workflow is adding a flowchart and using flow decision

e.g in here the flow ends if decision = True
image

@satya.allamraju I guess there are no activites related to return statement that we use generally in c# or .net

  • If you want to make the bot to forcefully come out of invoked workflow then you can use Throw Activity

Yes that is the best option so far. Thanks @jack.chan But it would be nice if UiPath adds such early-exit option as an activity instead of the make shift arrangements.

2 Likes

Absolutely @ushu - It would be nice if this is provided by UiPath so that the code looks tidy

Hey @satya.allamraju

The same is possible in UiPath as well.

In the .NET you will obviously return from conditional code paths like IF, Switch etc

I hope you are pointing the same.

Thanks
#nK

It’s pretty easy to come out from invoke workflow. Just use throw activity inside workflow and put the “invoke workflow” activity inside Try Catch block.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.