You need to sign in to do that
Don't have an account?
gweston
help iterating through soql result
I am trying to iterate through the result of a soql result and I am getting a number of errors.
public ApexPages.StandardSetController accountRecords{ get { if(accountRecords ==null){ return new ApexPages.StandardSetController( Database.getQueryLocator( [SELECT name FROM Service_Region__C WHERE Service_Region__c.Advisor_Account__c NOT IN (SELECT AccountId FROM Opportunity WHERE IsClosed =false)] )); } return accountRecords; Iterator<sObject> accountsIterator = accountRecords.getRecords().iterator(); while ( accountsIterator.hasNext() ){ sObject recordEach = accountsIterator.next(); recordEach.put('GEOPointe', geopointe.API(id1, accountRecords.Id, geopointe.API.units.MILES)); } } private set; }
One error is "Save error: Non-void method might not return a value or might have statement after a return statement."
and the second one is related to the geopointe.API :
: Method does not exist or incorrect signature: geopointe.API(Id, Id, geopointe.API.units)
Any help would be appreciated.
Write "return null" in the end of method in which you are facing the the "Save error: Non-void method might not return a value or might have statement after a return statement." issue and let me know the code from where you are getting this geopointe :
"recordEach.put('GEOPointe', geopointe.API(id1, accountRecords.Id, geopointe.API.units.MILES));"
Thanks
Ankit Arora
Blog | Facebook | Blog Page
Non-void method might not return a value or might have statement after a return statement : This error comes when all part of your method which has a return type does not return some value. In your case your getter does return accountRecords but it has a statement after it as well which means this is an unreachable code.
Method does not exist or incorrect signature : Compiler not able to find any such method in this class or any class which this calss is extenteding.
@ankit last night I went to bed cross posting , in morning again the same , I think we should set timings ,like in movies Dons have an area :)
Haha!! Good Idea, we should think over this.
Thanks
Ankit Arora
Blog | Facebook | Blog Page
Thank you for the quick reply. I am actually further along and got the class to save without errors.
"recordEach.put('GEOPointe', geopointe.API(id1, accountRecords.Id, geopointe.API.units.MILES));" was wrong it should have been geopointe.API.getDistance
I don't know if it works yet because I can't test it. Because I can not figure out to display temporary field GEOPointe.
Here is the updated code
and here is the page
I had the same issue, the error showed up was
Compile Error: Non-void method might not return a value or might have statement after a return statement. at line
My method was
private PageReference returnToPage(Account cloned)
Easy fix, - if not then 'return null' that's it