Uipath string null

code

#1

Does anyone know how to check for an unassigned string in uipath? Uipath seems to crash when an if statement looks for a null string. Not sure how to handle that. String.empty doesn’t seem to work, and if the string is unassigned uipath stops logging and nothing happens.


#2

You might just initialize or set the default value of the variable to ""
Then, it will have something stored in it.

You could also use = Nothing, I believe, but adds slight complexity.
Like,
If(variable=Nothing,False,variable=“ABC”)

If it’s empty then it sets the condition to False and if it’s not empty, it performs the condition.


#3

bool result = String.IsNullOrEmpty(yourString)


#4

I constantly get the error that the index was outside the bounds of the array, because it returns an empty string. Do you know how to fix this?Capture


#5

Solved. Worked for me