Return Activity inside Custom Activity Exits the Calling Workflow

I have a workflow that loops, and if a condition is met, it returns using a Return Activity. Otherwise, it continues with more steps after the loop is completed.

I’ve created a custom library using this workflow. However, when using this workflow as an activity from the library, instead of continuing after the loop (as expected), it exits the calling workflow entirely when the condition is met.

I’m not sure if this is intended behavior or a bug. I’m using UiPath Studio 2024.10.8

Hello @Augusto_Gonzalez

Is the Return activity triggered or skipped?

If the Return activity is triggered the workflow is terminated entirely.
If you just want to “jump out of the current loop” you should use a Break activity instead.

Regards
Soren

Yes, it works as you described, but I’m looking for a middle ground: I want the custom activity to terminate (exit the loop and skip the remaining steps inside the activity) without also terminating the workflow that invoked it.

For example, if I have a Log, the custom activity, and another Log, when using a Return inside the custom activity, the process logs the first message, exits the activity, and does not log the second message.

You are right. Calling “Return” activity in a custom activity causes termination of the workflow that contains the custom activity.

I suppose this is a bug.

Cheers