function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sam patilsam patil 

Create a checkbox “isActive” on Opportunity. Write a trigger such that if the Closed date is having today’s date then the isActive checkbox must be true. This scenario must work on the insert as well as on the update.

Best Answer chosen by sam patil
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Sam,

Can you try the below trigger. Update the API names of the fields as per your org.
 
trigger IsActive on Opportunity (before insert,before update) {
    
    for(Opportunity opp:Trigger.new){
        if(opp.closedate==system.today()){
            opp.IsActive__c=true;
            
        }
    }

}

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,
​​​​​​​