Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Add SObject Comparator/Comparable class #80

Open
jongpie opened this issue Aug 30, 2017 · 0 comments
Open

Add SObject Comparator/Comparable class #80

jongpie opened this issue Aug 30, 2017 · 0 comments

Comments

@jongpie
Copy link
Owner

jongpie commented Aug 30, 2017

I've had a few versions of a class called SObjectComparator (or SObjectComparable or something similar) over the years - the goal of this class is to pass in two versions of the same record and provide methods to check what fields have changed (if any). This would be helpful to have in Nebula for validating records in a trigger (#79), determining if a record is dirty and needs to be saved, etc.

Ideally, this works best in a trigger context - triggers have all fields populated on an sobject during a trigger, making it easy to compare the before & after values of every field. If SObjectComparator is used during a non-trigger context, then there is a greater chance that the sobjects do not match simply because they do not have the same fields populated in memory. Some additional checks need to be added to check for this - sobject.getPopulatedFieldsAsMap() had a bug until recently where not all populated fields were returned, but one of the most recent SF releases has fixed it, so it should be usable now.

@jongpie jongpie changed the title Add SObjectComparator Add SObjectComparator class Aug 30, 2017
@jongpie jongpie changed the title Add SObjectComparator class Add SObject Comparator/Comparable class Aug 30, 2017
@ghost ghost assigned jongpie Aug 31, 2017
@ghost ghost added the in progress label Aug 31, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant