Checking if Something is Empty String Stopped Working


#1

So I have been using a function in my workflow that checks to see if “aValue.Equals(”")" and it was working totally fine until now. All of a sudden it is throwing an error saying that the “Object reference not set to an instance of an object”

I have no idea why. If someone could help that would be great. Thanks.


#2

Hi.

You can solve this a few ways.
First I would try doing aValue.ToString.Trim.Equals(""), but I think that might not work
Second, you can set “aValue” to “” by default, either in the Variables tab or with an Assign, so it starts off with an initial value of empty string.
Lastly, you can embed a condition in your condition like so:
If(aValue isNot Nothing, aValue.Trim.Equals(""), True)

The last solution is not really needed but does add some robustness.
Second solution is probably easiest to implement.

Regards.


#3

For checking string variable is empty or not. Better use static methods string.isnullorempty(avalue)