+ Start a Discussion

In Apex, how to know number of fields updated in Update call

In Update trigger, Is there a way to know how many fields are updated? I have a scenario where a user should be able to update only one specific field on custom object.
There are more than 100 fields on custom object and I do not want to check old and new value for each and every field.

Thanks in advace for viewing this thread.
Karan Khanna 6Karan Khanna 6
you would have to use schema.describe method to get all fields of that object then loop through each field to check if old and new values are different, if yes then pick out those fields,, thats the only way which i could think of..

though I see you dont want to take this route but if you want User should be able to update only one field then why dont you restrict other fields through FLS?
Yes, that is the last option I have but I am looking for something out of the box available. thanks for your respone @Karan.