Out arguments not carrying value if exception is throw

Hi,

My scenario is that, In one of the workflows under ‘Process’ block I am throwing a business exception and using ‘Throw’.
I am using an IF block and checking some condition, if that is not met I am initializing my Out_Arguments a certain value and then Throwing Business exception.

Issue is that My Out argument are not carrying forward the initialized value instead they are having previous value. I tried the same in a dummy workflow.
It appears that if an exception occurs then Out arguments are not carried forward.

Any guidance on this will be very helpful.

2 Likes

@Faraz_Subhani,

If you are assigned the values after the exception occurred area then you will not get the out arguments values.

1 Like

@Faraz_Subhani
maybe you can wrap the critical part into a try/catch block and do the out argument assignment within the final block. I agree to @sarathi125 and would come to the same explanation

1 Like

@Faraz_Subhani

As my friends said, when any exception occurs then it won’t pass any arguments outside. If you want to read that value then pass it into Throw activity and read it outside.

I also have the same issue and trying the same procedure. It’s working fine.

1 Like

@lakshman Please may I know as to how are you suggesting to pass the value into throw activity?
Or please can you elaborate as to how you tackled this issue

1 Like

@Faraz_Subhani

Our input data is in Excel file and have to read one by one record and has to process it. Once processing of record completed will write Status and Remarks into excel file.

In Success case - Success, Record processed successfully

In Failed case - Failed, corresponding business rule exception.

That status Column value is in argument and it’s direction Out.

So, we are throwing business rule exception like below.

 new BusinessRuleException("Failed","Exception Message")

And then Catch block we are using Business Rule Exception to catch this exception and fetching values like.

               Status - Exception.Message.Tostring.Split(","c)(0)
               Remarks - Exception.Message.Tostring.Split(","c)(1)

Thanks for the reply but I am still confused, ok I will try to simplify with small demo


So, this is 1 block under process, where if certain conditions are not met I am throwing a business exception.
Now, I there is a counter(in this case) which needs to be incremented when next transaction item is being processed.
This incremented value of the counter is not being passed to Main block.
So when my next transaction item is processed the counter still has previous value.

1 Like

@Faraz_Subhani

Pass that counter value inside Throw activity and then catch it in Catch block section and assign that value to other integer variable.

Sorry, again a bouncer :slight_smile:, what exactly you mean by’ pass it inside Throw activity’, Throw activity doesn’t have any parameters where I can pass .

@Faraz_Subhani

It should be like this.

 new BusinessRuleException(out_Counter.Tostring)

In Catch section,

Create one Interger variable and say counter.

    Int counter = CInt(Exception.Message.Tostring)
4 Likes

Great! This thing worked in the dummy flow, will execute in check in the actual project.
Thank you very much, sure this post will help a lot of people as I wasn’t able to find a related post to this.
Will update after final implementation.

Thanks @lakshman @ppr @sarathi125 for your help, please keep up the good work:-)

2 Likes

@lakshman Just another query, what if there are more than 1 arguments that needs to be passed, also, what if I need to send a specific message with throw, as in place of message I am passing the argument.

@Faraz_Subhani

You can pass arguments and messages at a time.

    New  BusinessRuleException(var1.Tostring,var2.Tostring,"Exception Message1","Exception Message2")

Just you need to split it based on comma “,” as mentioned in earlier post and assign it to corresponding variables.

7 Likes

Great!, Thanks again:-)

1 Like

@lakshman any help with passing a browser type variable, because it’s not working for that an I am stuck as for my next transaction item the block is in attach browser and I am passing the same browser element to that.
If instead of passing the browser element I am indicating the html browser it throws error- ‘value does not fall within specified range’

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