• grani
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    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

Hi All
 
I have a particular question in trigger
 
I wrote a trigger After insert and After update. It effects to all the users but, it i want to reflect to a particular user for eg BA User (User name) . If this user updates or Insert any records i don't want to fire a trigger. So can you please hep me out with the Syntax
 

I've ran into this problem before which logically doesn't make sense to me.  It seems that when I make a change to an existing piece of code, force.com doesn't test my updated local code but instead uses the code on the server.  This creates a real problem when the server code throws an exception error or doesn't pass your test.assertEqual logic.

 

In my current situation, I have a class that changes the ownerid of a lead.  The problem with the server code is that I didn't account for converted leads so it's attempting to update converted records which isn't allowed.  I've corrected the code locally but can not get it pushed up to the server as the testing process continues to read only the server code (which has the error):

 

System.DmlException: Update failed. First exception on row 0 with id 00Q6000000TKaxSEAT; first error: CANNOT_UPDATE_CONVERTED_LEAD, cannot reference converted lead:

 

The server code uses this query:

for (Lead[] UpdateLead : [Select l.Id, l.OwnerId from Lead l where l.Owner_Expiration_Date__c <= :dExpDate and l.OwnerId <> :NewOwnerId]) {

 

My currected local code uses this query:

for (Lead[] UpdateLead : [Select l.Id, l.OwnerId from Lead l where l.Owner_Expiration_Date__c <= :dExpDate and l.OwnerId <> :NewOwnerId and l.ConvertedDate <> null]) {

 

My question is how do I get my code corrections to move to the server?  I've attempted "Deploy to server" as well as a simple "Save to Server" and either way the new code is not upload and the test logs show it's not being used.  I'm assuming I'm missing something but I don't know what that is.  Please help.

 

 

Here's a copy of the entire class:

public class clsLeadOwnerChange {
	public void LeadToUpdate(){
		List<Lead> LeadToUpdate = new List<Lead>();

		// Set Today's Date
		Date dExpDate = date.today();
		
		// Query for the Lead Queue 
		Id NewOwnerId = [Select q.QueueId from QueueSobject q where q.SobjectType = 'Lead'].QueueId ;
		
		// Query for Leads which have an Owner_Expiration_Date__c <= today (the less than adds a measure of security in case the scheduled class didn't run)
		for (Lead[] UpdateLead : [Select l.Id, l.OwnerId from Lead l where l.Owner_Expiration_Date__c <= :dExpDate and l.OwnerId <> :NewOwnerId and l.ConvertedDate <> null]) {
		
			// Loop through UpdateCon
			for (Lead l : UpdateLead) {
				// Change the OwnerID
				Lead lUpd = New Lead(ID=l.Id, OwnerId=NewOwnerId);
				LeadToUpdate.add(lUpd);
			}
		}
		update LeadToUpdate;
	}
}