34. Prevent account record from being edited if the record is created 7 days back.

Solution:

trigger AccountTrigger on Account (before update) {
        if(Trigger.isUpdate){ if(Trigger.isBefore){
                                       AccountTriggerHandle.preventAccEdit(Trigger.new);
                         }
         }
}
public class AccountTriggerHandle{ public static void
              preventAccEdit(List<Account> accList){ for(Account acc:accList){ if(acc.CreatedDate<System.today()-6){
              acc.addError(‘You cannot update
               account created 7 days back’);
                                             }
                             }
               }
}

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 :)