I have the following code:
Public Pagereference quickSave(){
for(Rights_Tracker__c RT : RightsTrackerList)
{
if(RT.Actual__c > RT.Agreement__c)
{
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Actual Bigger than Agreement'));
return null;
}
else
{
PageReference pageRef = Page.rightsTrackerEdit;
pageRef.getParameters().put('account', accountid);
return pageref;
}
}
}
I'm trying to display an error message when RT.Actual__c is greater than RT.Agreement__c.
When the error is displayed, I'm trying to return null to refresh the page. If there's no error, I want to upsert the list and return the new pageRef.
However I'm getting the following error:
Error: Class Compile Error: Non-void method might not return a value or might have statement after a return statement. at line 167 column 9
Line 167 is the for(Rights_Tracker__c RT : RightsTrackerList)
line, so I guess it can't detect my return statements in the conditionals. Am I doing something wrong or do I have to do it another way?
Thanks.