Assign activity - Object reference not set to an instance of an object

Hello all, does anyone can help me with this error ? I cannot send the file because is confidential, but, from you experience, I’m trying to read the pdf file with REGEX, and the result is almost perfect, I don’t know why it cannot read the quantity from the pdf, I have the error on “Assign” activity. As you can see, only the “Qty” data is not read, the rest is ok. Maybe the RGX code is not ok? but I so that is match. :frowning:

Thank you!

image
image

Hi @ovidiu_2088

Please make the variables/objects you are using it not null or empty to avoid this ‘Object Reference not set to an instance of an object error’

Hope this will help you. Thank you.

Hi

May be you can mention like this in Assign activity

row.Item(“Value”) = If(String.IsNullOrEmpty(ResultRGX(0).ToString.Trim), string.Empty, ResultRGX(0).ToString)

This will handle if there is no quantity value found from Regex and if so will pass null value to that row
Cheers @ovidiu_2088

Debug the flow and inspect the e.g. the result returned from the Matches
For a further analysis:

  • Set a breakpoint on the assign activity
  • Debug and get paused
  • explore e.g. within the immediat epanel variations of the regex patterns

Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

Hi,

Is there vertical tab (\v) in your string actually? I suppose it might be \r?\n instead of \v.

Regards,

The pdf file always contain something, so every time I have that quantity. I put your string but is not working, I have the same error. :face_with_raised_eyebrow:

I put also \n, \r , is the same.

I don’t know how can I do that! Maybe in the variable for “build data table” activity, in the default field, to write something ?

@ppr I will start to read all this debugging panels, maybe I will find something. but from what I see, I think that I don’t have an issue with RGX code, I think is something else.

Hi @ovidiu_2088,

As @Jobin_Joy mentioned, the error you are getting is because one of your variables is null. I would imagine it’s down to either row.item("Value") or ResultRGX being null, ResultRGX is more likely to be null.

Try running your workflow in debug, allow the code to throw the Object Reference error and then look at the Locals panel for your null variable. If it’s ResultRGX, you may need to alter your Regex pattern. If it’s row.item("Value"), check that your DataTable dtData is being picked up correctly and there is data present in the DataTable

1 Like

Hi, I’m back with solving. :slight_smile: . You are right about debugging, I saw that the RGX code was not ok how I build it and that’s why he cannot read what I need but now I changed it and is ok. Thank you very much for your time!

1 Like

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