Is there a default value I can specify for a string to avoid "Object reference not set to an instance of an object." error?

Hi,
I am trying to Assign a string variable at the beginning of Process.xaml in REF to read the in_Transaction variable, which is ‘Null’ or ‘0’. But I am being thrown out with below error. “Assign: Object reference not set to an instance of an object.”.

So I am thinking that default value to string variable would resolve this error?

Thx!

You are accessing the in_Transaction without assigning.

@Sachingoudar

Please ensure the in_TransactionItem value is mapped to the correct argument.

Yes this is my first line of code under Process.xaml, using Assign activity. And I have set the “Id” value of the transaction as NULL. So in this case I am trying to catch the Business rule exception using Try/catch where I have below code under Try block.

StringVar = in_TransactionItem.SpecificContent(“id”).ToString

Since here transaction value is NULL, it is giving me the above System exception whereas I am trying to catch business exception. How to resolve this?

@Sachingoudar

I guess it is giving Null Reference Exception here.

Put that assign activity in Try block and if exception occurs it will come to catch block where Null Reference Exception mentioned and here you throw Business Rule Exception then it will go to Business Rule Exception in Process Transaction State.

1 Like

That’s really cool idea @lakshman :slight_smile: That really fixed my prob.

But is that normal practice of throwing business exception under system exception?

1 Like

Hi @Sachingoudar,
Please check this link, this may help you handling the errors more specifically >>Check if value exists