Look Up Data Table

Hi All,

i have a data table contians 2 columns Customer name & User id,

i am using lookup data table to search customer name and extracting user id ,

i am not having any problem when the customer name data exist but if the customer name not exist how to handle,

i just given in lookup data table output value as string i.es str_Userhash

when i tried to check empty string or not in the below condition
i.es (String.IsNullOrEmpty(str_Userhash) Or str_Userhash.Trim=“” Or str_Userhash Is Nothing)

i am getting below error

Error :If: Object reference not set to an instance of an object.

kindly help me how to handle when lookup data not found

Hi @sivaramakrishna_raja

Try to intialise the str_Userhash value as “”

I think then the error can be avoided , because this error is due to the no value in the str_Userhash when costumer I’d u are searching doesn’t exist

Please mark it as solution if it helps

Hope it helps

Nived N :robot:

Happy Automation

In the Lookup you can assign the rowIndex to a variable. If the expression is not found the uipath returns -1 as the row index.
You then, still in the loop, put an IF with the condition index<>-1 to proceed with further actions.
Leave else blank and it will loop back to the next row if index = -1 (not found)

Watch this for detail UiPathTutorial 29-Compare two excel sheets and update the cells |Lookup Data Table |Excel Comparison - YouTube

sivaramakrishna_raja,

The solution is to remove your

Or st_Userhash Is Nothing

The reason is because your error message alludes to improper comparison syntax. In other words, a String variable cannot be compared as an Object. You’re obviously checking whether your string variable has something in it or not. “Is Nothing” is only used to see whether an Object has been initialized/set, not a basic variable type like Boolean, Int32, String or Char. You can think of Objects as complex variables that contain many basic variable types (and Methods, or functions) inside it.

And if I’m not mistaken, String.IsNullOrEmpty already does what your str_Userhash.Trim=“” does and should be safe to remove, but doesn’t hurt anything other than a few wasted CPU cycles.

Hi @sivaramakrishna_raja Check this below link,

Hope this may help you :smiley: