The curious case of SmartObjects and Nulls.
Is your property half empty or half null?
There is a little-known quirk with Nintex Automation K2 SmartObjects and how they handle null values, or rather, non-values.
I am not a computer scientist so I cannot comment on whether null should be considered a value or not, but I am intentionally framing the topic in this manner as it is that line of thinking in which null is a value that creates a very frustrating problem for the unaware.
The issue is if the service broker feeding your SmartObject, be it a REST service, MS SQL, Oracle, etc., returns a null value for a property you are evaluating in a conditional statement in a SmartForm rule, you will never receive a true if you are evaluating for “Is Empty”.
Curious Indeed.
There have been other areas in K2 SmartForms where type evaluation didn’t happen as expected. Form and view parameters, for example, can be picky about where the data type is text or number regarding how those evaluate within conditional statements. I have read Nintex Community posts on this topic, so I do know there is documentation on the web highlighting this behavior.
The null situation has caught two different customers in the last six months, so I thought I would give it some attention.
It can be a frustrating problem when the SmartForm you are developing just will not work the way you expect even though all the data you are seeing on screen says it should be. (Shout out to Rick, you know who you are.)
I’ve assumed that a null was empty, but null is null. SmartForms doesn’t have the C# equivalent of IsNullorWhiteSpace, so what is a developer to do?
In all the instances I have experienced, we were developing either custom services or stored procedures, so we were able to change the behavior instead of just returning null.
However, if you are in a situation where you do not have the ability to control return values, I can think of a few approaches you may try. I have not tried these personally, but this would be the path I would go down if I were in your situation.
The simplest approach is you might try assigning the SmartObject property as the value of a hidden data label on the view or form and then evaluate the label’s value not the SmartObject property directly.
If that fails, you could then try creating an expression (the little fx at the top of the design canvas in K2 Designer), that leverages a combination of functions to attempt to validate the property and return a value that could be evaluated.
Depending on the exact scenario it may take two data labels: one to hold the SmartObject property’s value, and one to which you assign the expression to store the result. It would be that second data label that you could then use in your advanced conditions.
If all else fails, sometimes it is a good idea to just take a step back and rethink your logic. Is there a different way to evaluate logic?
I would imagine that the behavior isn’t necessarily with SmartObjects themselves, but rather how the JavaScript powering SmartForms handles the scenario as I don’t recall having this issue inside of a K2 workflow.
Hope this helps a would-be K2 developer out there that is ready to rage quit because no matter what they do that seemingly valueless SmartObject property never evaluates as “Is Empty”.
Have you hit a quirky evaluation issue before in K2 SmartForms? Have you noticed this issue? Comment and share your thoughts.



Great topic! Yes there are a lot of unexpected behaviors in the smart form editor. The evaluation of text comparisons is usually broken. And it is bad enough that we have to write things like IF ( myVar = True) instead of IF (myVar), just because this editor is supposed to be for "Citizen Developers". Another one is the Mail Send action. Although it is best practice not to use it, it can be useful sometimes. Well the code is so legacy that it does not recognize new TLD as valid emails... I think everybody agrees that K2 should have had a major product upgrade in the last 5 years, unfortunately this was not on the menu with Nintex.