Advertisement
f1lam3ntx0

dr prefix on lead on firstname

Aug 21st, 2022
832
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1. Example 3:
  2.  
  3. The following trigger describes about when the leads are inserted into the data base it would add Doctor prefixed for all lead names. This is applicable for both inserting and updating the lead records.
  4.  
  5.  
  6.  
  7. Trigger drPrefixOnLeadTrigger on Lead (Before Insert, Before Update){
  8.  switch on Trigger.OperationType{
  9.   when BEFORE_INSERT{
  10.     drPrefixOnLeadHelper.drPrefixCheck(Trigger.new);
  11.   }
  12.   when BEFORE_UPDATE{
  13.     drPrefixOnLeadHelper.drPrefixCheck(Trigger.new);
  14.   }
  15.  }
  16. }
  17.  
  18.  Public with sharing class drPrefixOnLeadHelper{
  19.   public void drPrefixCheck(List<Lead> leadList){
  20.     if(leadList != null){
  21.       for(Lead ld : leadList){
  22.       ld.firstName = 'Dr'+ld.firstName;
  23.       }
  24.     }
  25.   }
  26.  }
Tags: Triggers
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement