Why does my snippet return a blank value for a field, rather than null or undefined?

So I’m providing a method for users to set criteria, and then I use a snippet to apply those criteria to another model which is then queried.

Here’s the first part of the snippet:

var $ = skuid.$,&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; //get the models from the page<br>&nbsp; &nbsp; search = skuid.model.getModel('SearchCriteria');<br>&nbsp; &nbsp; operatorsModel = skuid.model.getModel('SearchOperators');<br>&nbsp; &nbsp; typeModel = skuid.model.getModel('SearchCATG');<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; //get the first row which contains the criteria which we will use to set model conditions<br>&nbsp; &nbsp; var criteria = search.getFirstRow();<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; //get the values of fields in that first row<br>&nbsp; &nbsp; &nbsp; &nbsp; var paxCount = search.getFieldValue(criteria,'PAX__c',true);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.log("PAX Count is " + paxCount);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // this is an integer/double field and returns null or undefined if I run it without a value<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // if I run it with a value first, and then try to run it again without a value, it returns a blank value<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // ie not null or undefined, just empty.<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; var cargo = search.getFieldValue(criteria,'Cargo__c');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.log("Cargo is " + cargo); &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // this is a boolean and always returns true or false


the variable paxCount is the one I’m having issues with. If the user puts a value in the first time, e.g. 7 and executes the search, it all works fine. But if the user then deletes the value of that field in the UI (this field is ‘PAX__c’), I would expect that the variable paxCount would return a value of either null or undefined. But it’s not, it’s just returning a blank value, and my model condition still thinks it has something in it.


This is the part of the snippet where I try to set the value of the condition using paxCount, or I try to deactivate the condition if it is null or undefined:

&nbsp; &nbsp; //set the conditions on the Operators Model, from the values contained by search criteria&nbsp; &nbsp; var minPAX = operatorsModel.getConditionByName('minPAX',true);<br>&nbsp; &nbsp; &nbsp; &nbsp; if (paxCount !== null || undefined) {<br>&nbsp; &nbsp; &nbsp; &nbsp; operatorsModel.setCondition(minPAX,paxCount);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.log("Activated minPAX");<br>&nbsp; &nbsp; &nbsp; &nbsp; } else {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; operatorsModel.deactivateCondition(minPAX);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.log("Deactivated minPAX");<br>&nbsp; &nbsp; &nbsp; &nbsp; }


Any ideas as to why I’m getting an empty/blank value, when my expectation is that it should be null or undefined???


























so I managed to solve this one this morning with something that seems pretty obvious in hindsight. Essentially the condition was just returning an empty string, so I just created a condition to check for that, and if true, then set it to null instead:

var paxCount = search&#46;getFieldValue(criteria,'PAX__c'); if (paxCount === "") { paxCount = null; }&nbsp; &#47;&#47;do a bunch of other stuff &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
console&#46;log("PAX Count is " + paxCount);


seems simple looking at it now…grrrr.