• Marcus Stoll
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hi all - I'm trying to figure out the appropriate way to have a trigger to update a lead's status to "SDR Meeting Booked" if an event activity is created by someone whose user profile ID = 00eE0000000adW0.

Modifying some code I found elsewhere I have the first part down (changing status based off an activity being created), but I'm not sure how to modify this to account for the second piece.

Total developer noob here, so any help is appreciated!
 
trigger changeLeadStatus on Event (before insert, before update) {
    String desiredNewLeadStatus = 'SDR Meeting Booked';

    List<Id> leadIds=new List<Id>();
    for(Event t:trigger.new){
            if(String.valueOf(t.whoId).startsWith('00Q')==TRUE){//check if the task is associated with a lead
                leadIds.add(t.whoId);
            }
    }//for
    List<Lead> leadsToUpdate=[SELECT Id, Status FROM Lead WHERE Id IN :leadIds AND IsConverted=FALSE];
    For (Lead l:leadsToUpdate){
        l.Status=desiredNewLeadStatus;
    }//for
    
    try{
        update leadsToUpdate;
    }catch(DMLException e){
        system.debug('Leads were not all properly updated.  Error: '+e);
    }
}//trigger

 
Hi all - I'm trying to figure out the appropriate way to have a trigger to update a lead's status to "SDR Meeting Booked" if an event activity is created by someone whose user profile ID = 00eE0000000adW0.

Modifying some code I found elsewhere I have the first part down (changing status based off an activity being created), but I'm not sure how to modify this to account for the second piece.

Total developer noob here, so any help is appreciated!
 
trigger changeLeadStatus on Event (before insert, before update) {
    String desiredNewLeadStatus = 'SDR Meeting Booked';

    List<Id> leadIds=new List<Id>();
    for(Event t:trigger.new){
            if(String.valueOf(t.whoId).startsWith('00Q')==TRUE){//check if the task is associated with a lead
                leadIds.add(t.whoId);
            }
    }//for
    List<Lead> leadsToUpdate=[SELECT Id, Status FROM Lead WHERE Id IN :leadIds AND IsConverted=FALSE];
    For (Lead l:leadsToUpdate){
        l.Status=desiredNewLeadStatus;
    }//for
    
    try{
        update leadsToUpdate;
    }catch(DMLException e){
        system.debug('Leads were not all properly updated.  Error: '+e);
    }
}//trigger