Help me with this object reference error

I am using matches and regex to get matching strings in variable Laycan
but getting this error in assign

1 Like

@Gaurav07

It did not find any matching string based on given regular expression and because of that it is passing null value to it.

no it has find 2 matches and I printed them using for each but I want to store the two matches in two different variables

string was - LAYCAN - 09/24/2019 – 09/26/2019
and the matches it fount were - 09/24/2019 and 09/26/2019
I saved the collection output of matches activity in variable named Laycan
now I have used assign as
assign laycanstart = Laycan(0).tostring but its giving error

1 Like

What was the error?

object reference not set to an instance of an object. see screenshot above

help me write the code for stroring the output of matches which is a collection of two items in two different variables

@Gaurav07

Can you share the screenshot where in you are defining ‘Laycan’. How are you defining this?

This is working for me.

1 Like

tx for helping its working now. can you help me with handling the same workflow when there is not match found in that case I want to throw an exception message - no value found

Here it is.

image

1 Like

I need to use exception activity and log it into log file

In the else part, just Throw an exception and handle that.

1 Like

its again notemaildataextraction - Copy.zip (3.0 KB) working can you go through my xaml and let me know whats wrong

1 Like

Pls verify the scope of your “Laycan” variable.
Is it “visible” for both activities?

EDIT:
Variable scope is not the problem, but the data - there is no match => Laycan is NULL => error.
It is easy to find in debug mode. Do you use this?

Cheers

no there is value inside Laycan
plz check my xaml attached above

No, unfortunately there is not :frowning:

Run you WF in debug and check carefully variables at failure.

It looks like it’s not a logic issue. Please check for the types of variables you are trying to assign. Or any other properties or syntax.

Thanks,
Prasanta

@Gaurav07

I assume that there were logical errors with the flow in your xaml. I tried to fix the flow assuming your requirements. Kindly check the attached workflow.
emaildataextraction - fixed.xaml (17.3 KB)

1 Like