1

Using force:recordData to load a record data to a component, how can I check if a numeric field is null, to work with the aura:if syntax?

I've tried != null, != undefined, != '', empty(v.record.field__c), but none of those seem to work.

  • I just verified !=null, it just works fine. As an example -- <aura:if isTrue="{!v.simpleRecord.NumberOfEmployees != null}"> and it worked as expected. – Jayant Das Jul 26 '18 at 19:41
1

Following your syntax for the first three...

if your force:recordData's targetFields="{! v.simpleRecord }"

Wouldn't your expression check just be:

not(empty( v.simpleRecord.field__c ))

  • Actually, you are correct. For some reason, when using multiple conditions, if this check is the last parameter, then it doesn't work. I tried with the empty only, and it worked, then added other conditions after it and wrapped it all in an and, just like before, but keeping the empty first. Weird. Thank you! – Renato Oliveira Jul 26 '18 at 19:59
  • That's a really good find... I was just about to edit this post and say that even according to the reference docs, technically Integers / Decimals aren't supported with empty(). But maybe it's treated as a String in the simpleRecord.field__c – tsalb Jul 26 '18 at 20:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.