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.
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.
I am checking if the string is empty of nothing with your method String.IsNullOrEmpty(variable1.ToString.Trim)
But always get an error “Object reference not set to an instance of an object” if the string is Null.
I have tried an IF condition as:
variable1 is DBNull.value OR variable1.tostring.trim is (“”)
But it does not work too.
If (variable1 Is DBNull.Value, variable1.toString.trim=(“”), false) works great. But not if I need to check both True and False.
Can someone please help me with an issue.
Thanks
Anna
I don’t understand dbnull part. First from where our variable is coming? Second before call non-static methods on variable you should null-guard condition or use static methods. In your case check should be string.IsNullzOrEmpty(convert.ToString(variable))