Scenario:
Assume that you have field as Default( checkbox), If New Record Default field equal to True update all old records equal to False.
Code:
trigger makenewcheckboxtodefault on Account (before insert) { list<Account> acc=[select id,Name,Default__c from Account]; for(integer i =0; i<acc.size();i++){ if(acc[i].Default__c==true ){ acc[i].Default__c=false; } } update acc; }
Alternative method:
you can write this logic in Apex class and you can call Apex method name in a Trigger.
To readers:If you need any further assistance and if you find any mistakes let me know
Thanks:)
Create Anything!!! Control Anything!!!
Visit Our Latest Articles That You Must Need To Read. Also, Visit Our Website For More Articles.
ReplyDelete10 Pain Ideas You've Never Thought Of!
For More Visit Website
It 's an amazing and awesome blog. Thanks for sharing.
ReplyDeleteSalesforce CPQ Course
Salesforce CPQ Learning Path