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
sagarshahsagarshah 

Trigger to validate if the update is for rejecting timecard

I want to validate the timecard if it is updating for a rejection then only I want to continue.
pconpcon
Can you please expand on what you are trying to do?  This would be a relatively simple trigger if all you are doing is comparing a field on a object and if it is equal to a known value rejecting it.  For example:
 
trigger Timecard on Timecard__c (before update) {
    for (Timecard__c timecard: Trigger.new) {
        if (timecard.Status__c != 'Rejected') {
            timecard.addError('Timecards can only be updated to be rejected');
        }
    }
}

However, without more information about your object and a little more about the data in the object, that is the best I can do.