You need to sign in to do that
Don't have an account?
Ross Bai18
apex code - list - size() not return any value but null
hi, i have issue for this apex code.
loAccount2ndList is actually has the data return, but for some reason, when the code with loAccount2nd.size() > 0 logic, it seems not able to return any data but null.
i am just wondering if there is the way to query pass to the reference and having loAccount2ndList[0].value able to get some value.
many thanks.
loAccount2ndList is actually has the data return, but for some reason, when the code with loAccount2nd.size() > 0 logic, it seems not able to return any data but null.
i am just wondering if there is the way to query pass to the reference and having loAccount2ndList[0].value able to get some value.
many thanks.
public with sharing class PCL2CreateSessionImportData { public Account getAccount() { oppId = Apexpages.currentpage().getparameters().get('id'); List<Account> loAccount2ndList = [SELECT Id,OwnerId,PersonContactId,FirstName,LastName,,Outstanding_Judgements_Value__c,US_Citizenship_Value__c FROM Account WHERE PersonContactId in (SELECT ContactId FROM OpportunityContactRole WHERE Role = 'Realtor' AND OpportunityId = : oppId) and IsPersonAccount = true LIMIT 1]; if(loAccount2ndList.size()>0) loAccount2nd=loAccount2ndList[0]; else loAccount2nd = new Account(); return loAccount2nd; } public HttpResponse parseCreateSessionImportData() { String oppId = Apexpages.currentpage().getparameters().get('id'); List<Account> loAccount2nd = new List<Account>(); String RealtorEmail; if (loAccount2nd.size() > 0 && loAccount2nd[0].PersonEmail != null) RealtorEmail = ' '.substring(0, (80-string.valueof(loAccount2nd[0].PersonEmail).length())) + loAccount2nd[0].PersonEmail; else RealtorEmail = ' '.substring(0,80); } }
It seems to be some data issue. Please make sure that your soql query returns some data by either run your query in developer console or use system.debug(loAccount2ndList) before you check the size of the list.
Thank,
any value to it , hence the issue
please mark as solved if this helps you
may be at line 2 and comment line 24 , that’s move line 24 to line 2
any value to it - but as i use workbench to test query - by hardcode OpportunityId , there is a row of value return. thanks.
@manj_SFDC - thanks. List<Account> loAccount2nd = new List<Account>(); //this reference should be under the method -- parseCreateSessionImportData() -- enable reference outside method loAccount2ndList -- but i will try it as will.
i also think to simply the query of loAccount2nd or may be remove the LIMIT 1 and see what happen ?
first you need to remove extra comma :
second is:-
decleare public in class:-
public List<Account> loAccount2nd = new List<Account>();
and remove loAccount2nd decleration from line : 24,
Please let me know if you have any issue.
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh