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
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)
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.