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
SFDC BeginerSFDC Beginer 

Validation rules by trigger

Hi everyone,
this is the logic need to be work on.
I have one custom object Designation.
If type filed is Contract Flow and DocumentAttached  filed is True then HandOff Attached =True, otherwise False
How to implement the code for this.
i took the events as after insert, after update.
Kirti Deshpande 13Kirti Deshpande 13
Please try the below code - 
trigger DesignationTrigger on Designation(before update, before insert) 
{
      DesignationTriggerHandler.setValues(Trigger.New);
}


global class DesignationTriggerHandler
{
       public static void setValues(List<Designation> 
        newDesignationList)
       {
            for(Designation des : newDesignationList){
                   if(des.Type == 'ContractFlow' && des.DocumentAttached == true)
                      des.HandoffAttached = true;
            }

       }
}
​

Thanks,
KD