• ilai
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 4
    Replies

Transferring Leads individually or via the enhanced List View allows the users to check Send Email Notification checkbox and indicate that an email be sent to the person who the Leads has been transferred to. However, if 10 Leads are transferred, the new owner will get 10 emails.  This is a SFDC system default. 

Below is the trigger, when user transfer 3 Lead records, the new owner is getting 3 emails still.

Would like to ask how to write the trigger in order to send only 1 email to the new owner instead.

 

 

trigger changeOwnerEmailAlert on Lead (after update) {

    List<Lead> changeOwnerLead = new List<Lead>();
    
    for(Lead le: Trigger.new) {
            changeOwnerLead.add(le);
        
            User leadOwner = [SELECT Name,Email FROM User WHERE Id=:le.OwnerId];

            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            String[] toAddresses = new String[] {leadOwner.Email};
            mail.setToAddresses(toAddresses);
            mail.setSenderDisplayName('Salesforce Support');
            mail.setSubject('Lead(s) have been assigned to you');
            mail.setUseSignature(false);
           
            String msg = 'The following Lead(s) have been assigned to you';

            for(Lead l: Trigger.new) {      
                msg = msg + '<li>'+l.Name+' - '+l.Company+'</li>';        
            }      
            msg = msg + '</ol>';          

            mail.setHtmlBody(msg);
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

   }
}

  • May 12, 2009
  • Like
  • 0

Hi

 

I created a custom list button on Opportunity, and this list button is used in Contact - opportunity related list - to replace the New opportunity button.

 

The below url, i do not know what is 'lookupcmpgn' for and which object it refer to. Any ideas?

 

https://na1.salesforce.com/006/e?lookupcmpgn=1&retURL=/{!Contact.Id}&accid={!Account.Id}&conid={!Contact.Id}&opp6={!Contact.LeadSource}

 

Thanks.

  • April 20, 2009
  • Like
  • 0

Hi,

 

I am new to apex development. I got this error message when update a Parent account and the account hierarchy up to 4 levels.

 

I want to update a custom field value in all the child accounts if the parent account custom field value is changed.

 

Many Thanks.

 

---------------------------------------------------------------------------------------------------- 

Apex trigger setChildrenGSAFlag caused an unexpected exception, contact your administrator: setChildrenGSAFlag: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 001R000000FYfiqIAD; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, setChildrenGSAFlag: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 001R000000FYfrEIAT; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, setChildrenGSAFlag: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 001R000000FYfx1IAD; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, setChildrenGSAFlag: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 001R000000FYfzmIAD; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, checkAndSetGSAFlag: execution of BeforeUpdate caused by: System.Exception: Too many SOQL queries: 21 Trigger.checkAndSetGSAFlag: line 3, column 40 Trigger.setChildrenGSAFlag: line 43, column 5 Trigger.setChildrenGSAFlag: line 43, column 5 Trigger.setChildrenGSAFlag: line 43, column 5: Trigger.setChildrenGSAFlag: line 43, column 5 

-------------------------------------------------------------------------------------------------

trigger setChildrenGSAFlag on Account(after update){

    List<Id> AccountsUpdatedTrue = new List<Id>();  
    List<Id> AccountsUpdatedFalse = new List<Id>();  
    
      
    // List of parents where flag changed and became true  
    for (Integer i = 0; i < Trigger.new.size(); i++) {     
           if ((Trigger.new[i].GSA__c==true) && (Trigger.old[i].GSA__c==false))
           { 
                 AccountsUpdatedTrue.add(Trigger.new[i].Id);    
           } 
           else if ((Trigger.new[i].GSA__c==false) && (Trigger.old[i].GSA__c==true)){
                 AccountsUpdatedFalse.add(Trigger.new[i].Id);  
           }
    } 
    
    List<Account> updatedAccounts = new List<Account>();

    
    // Update the child accounts  
    Account[] ChildAccountsToUpdateTrue = [SELECT Id, parentId, GSA__c FROM Account WHERE parentId IN :AccountsUpdatedTrue];  
           
    for(Account pAcc: ChildAccountsToUpdateTrue)
    {   
                  
         pAcc.GSA__c=True;
         updatedAccounts.add( pAcc); 
    }
    
   
    
    Account[] ChildAccountsToUpdateFalse = [SELECT Id, parentId, GSA__c FROM Account WHERE parentId IN :AccountsUpdatedFalse];  
    for(Account pAcc: ChildAccountsToUpdateFalse)
    {   
         pAcc.GSA__c=False;
         //add GAM Team  for this children
         updatedAccounts.add( pAcc); 
    }
    
       
    update updatedAccounts;


}
  • April 14, 2009
  • Like
  • 0

Hi,

 

I have few validation rules, is that possible that the validation rules can be fire by preset sequence.

E.g, validation on first name & company name, I would like to have the rules to check on company name then only check on first name.

 

How does the sequence of execution of validation rules in salesforce works?

 

 

Many thanks.

  • April 14, 2009
  • Like
  • 0

Hi,

 

Would like to ask how to change/remove the reports to display in standard object home page (Account, Lead etc.)

 

Thanks.

  • April 09, 2009
  • Like
  • 0

Hi,

 

Would like to know is that a way to disable the attachment feature on Send Email?

 

 

Thanks

  • March 28, 2009
  • Like
  • 0

Hi,

 

Would like to ask whether the Add new Note page can be customize? How to remove field from add new note page?

 

Thanks

Message Edited by ilai on 03-26-2009 06:33 PM
  • March 27, 2009
  • Like
  • 0

Hi,

 

Would like to ask how to set a field to readonly immediately when a checkbox is checked on standard object Edit page.

 

Can this be done by using VisualForce?

 

Thanks.

  • March 26, 2009
  • Like
  • 0

Hi,

 

Would like to ask it is possible to set a field to readonly immediately when a checkbox is checked on Edit page (E.g. account)

 

Thanks,

  • March 26, 2009
  • Like
  • 0

Hi,

 

I am new to apex development. I got this error message when update a Parent account and the account hierarchy up to 4 levels.

 

I want to update a custom field value in all the child accounts if the parent account custom field value is changed.

 

Many Thanks.

 

---------------------------------------------------------------------------------------------------- 

Apex trigger setChildrenGSAFlag caused an unexpected exception, contact your administrator: setChildrenGSAFlag: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 001R000000FYfiqIAD; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, setChildrenGSAFlag: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 001R000000FYfrEIAT; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, setChildrenGSAFlag: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 001R000000FYfx1IAD; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, setChildrenGSAFlag: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 001R000000FYfzmIAD; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, checkAndSetGSAFlag: execution of BeforeUpdate caused by: System.Exception: Too many SOQL queries: 21 Trigger.checkAndSetGSAFlag: line 3, column 40 Trigger.setChildrenGSAFlag: line 43, column 5 Trigger.setChildrenGSAFlag: line 43, column 5 Trigger.setChildrenGSAFlag: line 43, column 5: Trigger.setChildrenGSAFlag: line 43, column 5 

-------------------------------------------------------------------------------------------------

trigger setChildrenGSAFlag on Account(after update){

    List<Id> AccountsUpdatedTrue = new List<Id>();  
    List<Id> AccountsUpdatedFalse = new List<Id>();  
    
      
    // List of parents where flag changed and became true  
    for (Integer i = 0; i < Trigger.new.size(); i++) {     
           if ((Trigger.new[i].GSA__c==true) && (Trigger.old[i].GSA__c==false))
           { 
                 AccountsUpdatedTrue.add(Trigger.new[i].Id);    
           } 
           else if ((Trigger.new[i].GSA__c==false) && (Trigger.old[i].GSA__c==true)){
                 AccountsUpdatedFalse.add(Trigger.new[i].Id);  
           }
    } 
    
    List<Account> updatedAccounts = new List<Account>();

    
    // Update the child accounts  
    Account[] ChildAccountsToUpdateTrue = [SELECT Id, parentId, GSA__c FROM Account WHERE parentId IN :AccountsUpdatedTrue];  
           
    for(Account pAcc: ChildAccountsToUpdateTrue)
    {   
                  
         pAcc.GSA__c=True;
         updatedAccounts.add( pAcc); 
    }
    
   
    
    Account[] ChildAccountsToUpdateFalse = [SELECT Id, parentId, GSA__c FROM Account WHERE parentId IN :AccountsUpdatedFalse];  
    for(Account pAcc: ChildAccountsToUpdateFalse)
    {   
         pAcc.GSA__c=False;
         //add GAM Team  for this children
         updatedAccounts.add( pAcc); 
    }
    
       
    update updatedAccounts;


}
  • April 14, 2009
  • Like
  • 0

Hi,

 

Would like to ask how to change/remove the reports to display in standard object home page (Account, Lead etc.)

 

Thanks.

  • April 09, 2009
  • Like
  • 0

Hi,

 

Can anyone tell what is the organization wide SOQL limit per day?

 

Regards,