I HAVE ALSO TRIED "isEmpty()"
When i create new User Account and login with that credentials, it gives me this problem if admin doesnt have set thier values yet !!!
AllotmentList = [select id, Days_Remaining__c from PTO_Allotment__c where Year__c =:year and Employee__c=:EmployeeList[0].id LIMIT 100]; //access only Current user Allotment details //to handle Listoutof Bound Exception wrote if-else
if(AllotmentList.size()>0)
{
requests.PTO_Allotment__c=AllotmentList[0].id;
requests.Days_Remaining__c=AllotmentList[0].Days_Remaining__c;
}
else
{
//write a code when AllotmentList is empty ....
}
Attribution to: Nilesh
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/33160