Losing argument value when passing a business exception

I am populating a string argument by scraping data in a workflow in the try and then throwing a business exception if it is missing a required field and catching it in the same workflow. Somehow after the throw, the argument becomes null and I can’t pass it out of the workflow . I need to pass it out to be able to use it in an excel log. Any idea on how to pass it out successfully?

Hi @hannahscott216,

Welcome to UiPath Community !!

Yes, Whenever you throw an exception the value in variable & Arguments will be cleared (Null). If you want to pass the value another workflow then don’t the exception there.Just a create a assign using businessexception which was created already,

Businessexception = new BusinessRuleException(“Your Business Error Message”)

Use the assign activity where have thrown the exception actually now. Once you have passed value to another throw the exception the when you no need of any value of variable/arguments.

Hope this will be helpful for you !!

Thanks in advance,
Jayavignesh G

HI,

If possible, can you share screenshot of your workflow?
If you try to pass out or in/out argument to caller workflow when exit the workflow due to exception, it won’t set value correctly. In this case, we can use Exception.Data property OR exit normally with passing information for the exception.

Regards,

Types that are passed by value behave like this. If it would be a reference type argument, the value could be kept upon exception.

For illustration:

So, an alternative to what’s been suggested already, you could change your argument type to something that’s passed by reference, like a dictionary.