Out argument value is found in try block but becomes empty in finally block

Hi there,

In try block i am getting a text as a string which will be stored under argument in a workflow. Within the try block i am able to pass through but in finally block it returns empty. Is there any alternative way for this? Try is my process, catch is business or system exception amd finally is to send emails for those sucess or exceptions.

@mark_rajkumar1

Please check the Scope of your Variable

Debug the process and check that variable in Immediate panel.In Try block to final block observe the variable

Hi @mark_rajkumar1

I am not facing any problem, I initalized a value to the out arguement in the Try block and used throw activity to throw exception to catch, then it went to final block.

I have checked the argument value in the final block it was showing the values in the argument.

In your flow, before initializing data to the argument the exception occured and it was directly going to catch block that’s why the argument was showing empty.

Hope you understand!!

@mark_rajkumar1,

That’s the expected behavior. If you want to return some value even in case of error, declare your argument with direction In/Out.

This will persists the value.

Sample code:
PersistArgumentValue.zip (4.1 KB)

Output:
image

Thanks,
Ashok :slight_smile:

@ashokkarale i cannot see the zip flow. Instead can u put as screenshot here. Thanks!

Hi @mkankatala im my catch exception i hVe to to indicate business or system by assigning variable. In that case how do i bring the argument to final block?

Hi, I think the root cause is when the workflow in try throw any exception, all the ouput is empty

Okay @mark_rajkumar1

Got it you want to store the Exception catched in the Catch block and you want to bring it to Final block right.

Create two catches in the catch block,
→ First one is Business Exception catch and create a variable called BusinessException_Var and the datatype is UiPath.Core.BusinessRuleException. Inside this catch take an assign activity and inititalize the exception to the variable as below,

- Assign -> BusinessException_Var = exception

→ Create seond catch in catch block,
→ Second one is System Exception catch and create a variable called SystemException_Var and the datatype is System.Exception. Inside this catch take an assign activity and initialize the exception to the variable as eblow,

- Assign -> SystemException_Var = exception

→ In Finally block insert an If condition to check the condition,

- condition -> BusinessException_Var isnot nothing
- Place mail activity to send Business Exception

- Condition -> SystemException_Var isnot nothing
- Place mail activity to send System Exception

Check the below workflow for better understanding,
Sequence3.xaml (14.3 KB)

Hope it helps!!

Hi @mkankatala ,

Thats not the issue. My workflow is same.as what u shared. I wan my argument from try move to final.

Your query is quite confusing could you be more specific by showing any screenshot… @mark_rajkumar1 which was helpful for our understanding.

In try block i am getting a text as a string which will be stored under argument in a workflow. Within the try block i am able to pass through but in finally block it returns empty @mkankatala

Yes what is the work around @Duy_Luong_Minh

@mark_rajkumar1,

Just change the direction of your argument to In/Out.

Main.xaml

Child.xaml

Thanks,
Ashok :slight_smile:

Hi @ashokkarale so for my case will be in try block i pull argument as in/out from a inner workflow and then bring it over to finally block. Am i correct?

@mark_rajkumar1,

No need to do anything in final. The argument will return it’s value.

Thanks,
Ashok :slightly_smiling_face:

Give me a clarification… @mark_rajkumar1

Are you invoking the child xaml to the Parent xaml. If any exception got in child xaml then you want to get the out argument value from the Child xaml to Parent xaml.

Am I right…? Correct me If I am thinking wrong.

@mkankatala yes this is what i meant

Okay @mark_rajkumar1

I have made a workflow for you follow the same steps. In the Child xaml don’t use the Rethrow activity in cache block, Instead of using rethrow use the Assign activities.

Check the below workflow for better understanding,
Forum Usecase.zip (4.7 KB)

Hope it helps!!

@mkankatala can show me as screenshot as i m unable to download

I uploaded the total workflow click on that file it will download and extract the file.

I have made two workflow it’s difficult to share screenshots… @mark_rajkumar1

Try downloading the below file, Consider Main xaml and Sequence xaml only.
Forum Usecase.zip (77.1 KB)