Solved

Check if string variable is empty

  • 4 April 2017
  • 5 replies
  • 430 views

Hi,

 

Nintex newbie here. happy.png

I am setting a string variable from a field in a list item. The field is optional, so I need to know whether the variable contains a value or not. 

I am using a 'Run If' action to check the variable, but I only get options to check if the variable is 'equals' or 'not equals' to a value. There is no 'is empty' option.

I created another variable, and I am not setting a value to it, thereby leaving it null, and then I am comparing the two variables. It's not working, however.

Is there another way I can use to do this?

201408_pastedImage_2.png

 

Many thanks in advance! 

 

Kasia.

icon

Best answer by TomaszPoszytek 4 April 2017, 16:47

View original

5 replies

Userlevel 7
Badge +17

Hello again Kasia  Certainly, for "Run If" there is no such possibility

I did the following workaround for such purpose:

  1. I have defined a text variable, but didn't set any value to it -ex.: var_EmptyString;
  2. Then I made a comparison in "Run If": variableToCompareIfEmtpy is equal var_EmptyString.

Regards,

Tomasz

Hi again!

Thanks for your reply. 

If you look at my screenshot above, I think I did exactly what you described. And it just doesn't work. The code should not run if the variable is empty, right? But it runs.

Kasia.

Userlevel 7
Badge +17

Oh... My bad. I haven't deeply read your question, just scrolled the text and thus I got not a complete view  sorry.

But on the other hand for the "Text" variables in "Run If" action you do have the option "is empty":

Maybe the variable you are trying to inspect is not a text, but a collection or sth?

I now realized that I used that workaround for the "Wait for Field Change in Current Item" action to check if the field "Check-out" is empty or not.

Regards,

Tomasz

YES! That was the problem. So silly... My variable was a Person, not string. That's why I didn't have the 'is empty' option.

Thank you!

Badge +9

To compare against a Blank variable in Office 365 you need to create 2 variables.

vtxtBlank1 = blank

vtxtBlank2 = blank

Then in the workflow set vtxtBlank2 = vtxtBlank1 which will effectively give you a Null value rather than blank

Then you can use the run if vtxtColumn1 = vtxtBlank2 (null)...

There are a few post regarding this.

Reply