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

Compile Error - non-Void method might not return a value -
I'm not sure what I'm missing on this code. Any suggestions? Thanks in advance for your assistance.
I keep getting this error (Save error: Non-void method might not return a value or might have statement after a return statement. ) on the update opptysToUpdate; line the end of this method:
public with sharing class CurrentPumpASP { Date currentDate = date.today(); Integer currentYearDate = currentDate.year(); String currentYear = String.valueof(currentYearDate); Opportunity writePumpASP(){ List<Opportunity> opptysToUpdate = [SELECT o.id, o.name, o.ASP__c, o.Product_Product_Group__c, o.Account.Primary_GPO__c FROM Opportunity o WHERE o.Type = 'MMS' AND o.ASP__c = NULL]; for(Opportunity pumpOpptys : opptysToUpdate ){ pumpOpptys.ASP__c = [SELECT Year__c, Pump_ASP__c, Primary_GPO__c, DTS_Pump_Type__c, CreatedDate FROM PumpASP__c WHERE Year__c = :currentYear AND DTS_Pump_Type__c = : pumpOpptys.Product_Product_Group__c AND Primary_GPO__c = : pumpOpptys.Account.Primary_GPO__c].Pump_ASP__c; opptysToUpdate.add(pumpOpptys); } if(!opptysToUpdate.isEmpty()){ update opptysToUpdate; } } }
Description Resource Path Location Type
by defining the method as "Opportunity writePumpASP() {" the compiler is expecting that method to return an opportunity. In this case, it doesn't look like you actually want to return anything...you're just performing an action.
in that case, you can just define your method as:
public void writePumpASP() {
...
}
All Answers
JoAnn,
You might need to further define the method. Try
Best Regards,
Mike
by defining the method as "Opportunity writePumpASP() {" the compiler is expecting that method to return an opportunity. In this case, it doesn't look like you actually want to return anything...you're just performing an action.
in that case, you can just define your method as:
public void writePumpASP() {
...
}
writePumpASP() method is expecting an Opportunity object as the return type, however you are not returning anything after the update call. if you change the method return type to void, you should not see the error.
Mike,
That was it! It was
Thank you so much!
Thanks Mike