Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Example 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.
- Trigger drPrefixOnLeadTrigger on Lead (Before Insert, Before Update){
- switch on Trigger.OperationType{
- when BEFORE_INSERT{
- drPrefixOnLeadHelper.drPrefixCheck(Trigger.new);
- }
- when BEFORE_UPDATE{
- drPrefixOnLeadHelper.drPrefixCheck(Trigger.new);
- }
- }
- }
- Public with sharing class drPrefixOnLeadHelper{
- public void drPrefixCheck(List<Lead> leadList){
- if(leadList != null){
- for(Lead ld : leadList){
- ld.firstName = 'Dr'+ld.firstName;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement