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.$, <br> //get the models from the page<br> search = skuid.model.getModel('SearchCriteria');<br> operatorsModel = skuid.model.getModel('SearchOperators');<br> typeModel = skuid.model.getModel('SearchCATG');<br> <br> //get the first row which contains the criteria which we will use to set model conditions<br> var criteria = search.getFirstRow();<br> <br> //get the values of fields in that first row<br> var paxCount = search.getFieldValue(criteria,'PAX__c',true);<br> console.log("PAX Count is " + paxCount);<br> // this is an integer/double field and returns null or undefined if I run it without a value<br> // if I run it with a value first, and then try to run it again without a value, it returns a blank value<br> // ie not null or undefined, just empty.<br> <br> var cargo = search.getFieldValue(criteria,'Cargo__c');<br> console.log("Cargo is " + cargo); <br> // 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:
//set the conditions on the Operators Model, from the values contained by search criteria var minPAX = operatorsModel.getConditionByName('minPAX',true);<br> if (paxCount !== null || undefined) {<br> operatorsModel.setCondition(minPAX,paxCount);<br> console.log("Activated minPAX");<br> } else {<br> operatorsModel.deactivateCondition(minPAX);<br> console.log("Deactivated minPAX");<br> }
Any ideas as to why I’m getting an empty/blank value, when my expectation is that it should be null or undefined???