Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Salesforce by (11.9k points)

I would really appreciate if someone can guide me to check if a particular field is included in update call inside a before/after update trigger. Many thanks.

1 Answer

0 votes
by (32.1k points)

All the fields are present in the trigger so, to ascertain if a specific field had been modified you have to retrieve a previous version of the row using oldMap which is Map<ID, sObject> and compare the values in old and new. For example:

trigger CaseOnParticularFieldUpdate on Case (before update) {

    for (Case c: Trigger.new) {

        Case oldCase = Trigger.oldMap.get(c.ID);

        if (c.Field != oldCase.Field) {

            // field was updated, do some magic here

        }

    }

}

To learn in-depth about Workflow in Salesforce, sign up for an industry based Salesforce Course.

Related questions

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...