Set Hot Rating for Media Industry Accounts

This trigger updates an Account’s Rating to “Hot” whenever its Industry field is set to “Media,” whether during creation or updates.

For additional examples, explore this YouTube playlist.

Solution:

trigger AccountTrigger on Account (before update) {

            if(Trigger.isUpdate){ if(Trigger.isBefore){
                  AccountTriggerHandler.updateIndustryRating(Trigger.New, Trigger.oldMap);
         }
     }
}
         public class AccountTriggerHandler {
             public static void updateIndustryRating(List<Account>
                  accList,Map<Id,Account> oldMap){ for(Account
                  acc:accList){ if((oldMap==null &&acc.Industry==’Media’)
                            || (acc.Industry==’Media’ && acc.Industry != oldMap.get(acc.Id).Industry)){
                            acc.Rating=’Hot’;
                      }
            }
      }
}

Want to Apply As Content Writer?

Leave a Comment

Your email address will not be published. Required fields are marked *

Shopping Cart

Let's get you started!

Interested in writing Salesforce Content?

Fill in this form and we will get in touch with you :)