Throw out Argument along with Business Rule Exception

Hi,

I would like to pass an out argument along with a business rule exception back to the main.xaml from a Try/Catch in a separate workflow.
I understand I’m to use something along the lines of exception.data(“variablename”)=value but I’m not sure exactly how to do this.
Could somebody explain how to do this please?

Thanks

1 Like

Let us say you have an exception “Order not found” and you can add this to a variable for example,
str_ExceptionReason = “Order not found” and you can throw the exception with New BusinessRuleException(“This exception is in particular fille.xaml”+str_ExceptionReason)

Thanks for your help, unfortunately this isn’t exactly what I’m looking for.
I’m looking to use the out argument in the main.xaml for further processing so i don’t want this to be tied in with the exception message.

So i will have the exception message, and the out argument assigned back to a variable in the main.xaml.

I’m not sure that there is a way to directly funnel out a variable when an exception occurs. Instead, you will have to handle what will happen in the event of an error by use of Try Catch. In cases like these (for example, wanting to output a datatable in the middle of a For Each that failed), I will catch the exception in my Try Catch, write the DataTable out to my out_dtVariable, and use ‘Break’. This way, it will cleanly leave the workflow and allow for the standard arguments to make their way out, along with your error message. Alternatively, I believe the Terminate Workflow activity works this way.

Hello!

I managed to pass out an argument using BusinessException.Data Dictionary.

In an Assign Activity try the following:

BusinessException.Data("variableName") = value

Once you set this, you can use Throw activity to throw an error and catch it with Try/Catch.
In the Catch block, you have access to the exception.Data(“variableName”) and you can send it as “in_Argument” to another workflow and use it for your logic.

2 Likes

Hello,

I do not see BusinessException.Data here. Could I get some help with this please? Thank you.

image

It’s a property of the Exception object. So if you are creating a new exception, initiate the BusinessRuleException first and then assign to the Data:

brex  = new BusinessRuleException("Message you want to pass.")
brex.Data("key") = "value you want to pass"
1 Like

Thank you for the reply!

I am still having trouble with this… I cannot put brex.Data in the Assign activity before the Throw activity, says “no items”. Is there a way to add this to the same Throw activity? I need to be able to pass the config message and the strDebtStatus variable. The Throw activity then goes back two children workflows back to the parent where I need it.

image

Try like this:

1 Like

OMG it worked!!! Thank you SO much, this is HUGE!!! thank you thank you thank you!!!

1 Like

Follow the below procedure,
1)Open the Process.xaml,
2)use one fresh try-catch inside the process.xaml
3)do your process inside the try
4)now the throw will come inside business rule exception.
5)it will get handled there itself,
6)now the value will remain safe with out argument
7) now you can use the out argument in process.xaml and use the variable in finally part.

If it works, Great to hear

Now exception will handled inside, now argument will come out,

Meanwhile for updating the queue status to business exception, send one flag argument out from this business rule exception, and use one if condition outside, and rethrow it, so it will update the queue status to correct status