Activity Forums Salesforce® Discussions How to compare old and new values in trigger in Salesforce ?

  • MOHIT

    Member
    February 20, 2020 at 2:27 pm

    To compare the old value and new value in trigger we can use trigger new map and trigger old map.

    Basically, to compare old field value of record with the new value in trigger we need to access trigger.oldmap and trigger.newmap. Salesforce provides trigger.oldmap where in all the old records are stored in map with keyset as their id's. We can compare the old values with new values as in the below example. Lets understand how we can implement such a data validation by getting old value in triggers.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos