• paith
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

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