You need to sign in to do that
Don't have an account?
MasahiroY
How to check if the Integer is blank?
I'm working on Apex, and enconuter a problem how to check the blank value in integer varibale. Here're the codes.
Pass the number input from lightning:input to Apex Class.
component
Switch the condition query in Dynamic SOQL, if !=null, then skip this WHERE clause.
Apex
However, this returns that default value of searchValue is null
If you entrer any value, it determined as !=null
If you erase the value and it's determied !=null but no value (blank?)
Do you know how to check if the Interger is blank?
I tried these but they didn't work.
Pass the number input from lightning:input to Apex Class.
component
<aura:attribute name="searchValue" type="Integer"/> <div class="flex-item space-digit text-overflow-hide"> <lightning:input type="number" name="Limit" label="Value" value="{!v.searchValue}" onchange="{!c.onSearchTermChange}" /> </div>
Switch the condition query in Dynamic SOQL, if !=null, then skip this WHERE clause.
Apex
if (searchValue!=null){ searchQuery += ' AND Billing_Total__c=:searchValue '; }
However, this returns that default value of searchValue is null
If you entrer any value, it determined as !=null
If you erase the value and it's determied !=null but no value (blank?)
Do you know how to check if the Interger is blank?
I tried these but they didn't work.
if (searchValue!=null || String.isNotEmpty(String.valueOf(searchValue)))
if (searchValue!=null || String.isNotBlank(String.valueOf(searchValue)))Thanks for your advice!
Yes, you can check from following methods. let me know if it help you and marking it as best.
Thank you.
I uploaded a demo. It shows when I enter 0, yes it skip the where condition and works. But if I erase the value from the input field, it doesn't hit (since it's considered !=0) But it's not null, nor blank. How you detect the integer field is erased?
https://drive.google.com/file/d/11vgnRtqIGLRMsbda3pLl9z3pjWvJM8wX/view?usp=sharing (http:// https://drive.google.com/file/d/11vgnRtqIGLRMsbda3pLl9z3pjWvJM8wX/view?usp=sharing)