"I'm getting a text value during the process

“I’m getting a text value during the process. I’m using Throw to raise a Business Exception. But when I try to access that text value in Set Transaction Status, it is coming as null. Does using Throw cause all values to become null?” how can i get the value

Hi @T_Y_Raju

Can you share more details on this?

The value variable you are referencing is - defined as a local variable in the workflow where you are throwing business exception? right?

if yes, then that variable needs to be passed to set transaction status if you want to access that variable in there.

But why do you want to access that value there?

Hi @T_Y_Raju
As per my understanding,
Declare a string variable errorReason at the main scope, wrap your logic in a Try-Catch block, throw the BusinessRuleException inside the Try with a custom message, catch the exception and assign its message to errorReason, then use Set Transaction Status after the Catch with status set to Failed and reason set to errorReason.

Happy Automation!

Hi @T_Y_Raju

Use a Variable with Wider Scope

Make sure the variable holding the text value is declared outside the Try-Catch block (e.g., at the Sequence or Workflow level) so it doesn’t get lost when the exception is thrown.

  1. Store the Value in TransactionItem

Before you use Throw, assign the value to a specific key in the TransactionItem:

TransactionItem(“ErrorMessage”) = yourTextValue
Throw New BusinessRuleException(“Something went wrong”)

Then in Set Transaction Status, you can retrieve it using:

TransactionItem(“ErrorMessage”).ToString

Try this will be working before that you can pass message boxes for making sure bot is moving at right direction

Hey @T_Y_Raju When you use the Throw activity to raise a BusinessRuleException, and then try to access a variable like string afterwards (e.g., in Set Transaction Status), it comes up as null because.The Throw activity ends the current workflow execution immediately it jumps to the Catch block.Any variables set before the Throw inside the Try block may not be carried over, especially if they’re not scoped correctly or not arguments passed out of the workflow.If the value is set in a sub-workflow, and it’s stored in a local variable, it will not be accessible in Process.xaml or Set Transaction Status.

Handle this error
Declare a shared variable at the top level of Process.xaml or even better, in Main.xaml if you want to use it in Set Transaction Status.

errorMessage = “Invalid Invoice Format”
Throw New BusinessRuleException(errorMessage)

cheers