You need to sign in to do that
Don't have an account?

string is blank or null
Hi ,
In the below written code , Lst has nothing, hence recentLoanCycle variable is not getting initialized, but it is still entering the if statement where i am checking if string is null or blank.
Please help!!
list<Lead> lst = new list<Lead>();
lst = [select Id ,Status, Loan_Cycle__c, client__c from lead
where (Product_code__c = 891 OR product_code__c = 894 OR product_code__c = 915)
AND client__c = '0018A000008XOQ4' order by createddate DESC LIMIT 1];
if(lst.size() > 0 && lst != null)
{
string recentLoanCycle = lst[0].loan_cycle__c.substring(1,2);
}
if(recentLoanCycle != null && recentLoanCycle != '')
{
system.debug('asdfsa' + recentLoanCycle);
}
In the below written code , Lst has nothing, hence recentLoanCycle variable is not getting initialized, but it is still entering the if statement where i am checking if string is null or blank.
Please help!!
list<Lead> lst = new list<Lead>();
lst = [select Id ,Status, Loan_Cycle__c, client__c from lead
where (Product_code__c = 891 OR product_code__c = 894 OR product_code__c = 915)
AND client__c = '0018A000008XOQ4' order by createddate DESC LIMIT 1];
if(lst.size() > 0 && lst != null)
{
string recentLoanCycle = lst[0].loan_cycle__c.substring(1,2);
}
if(recentLoanCycle != null && recentLoanCycle != '')
{
system.debug('asdfsa' + recentLoanCycle);
}
So the code is :
string recentLoanCycle;
list<Lead> lst = new list<Lead>();
lst = [select Id ,Status, Loan_Cycle__c, client__c from lead
where (Product_code__c = 891 OR product_code__c = 894 OR product_code__c = 915)
AND client__c = '0018A000008XOQ4' order by createddate DESC LIMIT 1];
if(lst.size() > 0 && lst != null)
{
recentLoanCycle = lst[0].loan_cycle__c.substring(1,2);
}
if(recentLoanCycle != null && recentLoanCycle != '')
{
system.debug('asdfsa' + recentLoanCycle);
}
Try this!
use below updated code.
Hope this will work
make it solved if its work.
Thanks
karthik