Added a way to present timeline data using an Apex class #108
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In my project I had the requirement to show data in the timeline that is not available in salesforce objects, such as data that is produced by calculating and aggregating existing data, or even data that is not in Salesforce and needs to be retrieved by an API. I have added a way to show this data in the Timeline by adding a special custom metadata that references an apex class. The apex class implements an interface and provides the data to be showed in the timeline. I have included a simple example in the ContactCustomTimelineData.cls apex class.
To use the apex class you just specify the following string "apex:[classname]" in the Relationship Name of the custom metadata record. Take a look at the included sample metadata file called "Contact_Custom". I didn't want to create a new field as I wanted to keep the changes to a minimum, but I would say it would be better to create a field for this kind of metadata types.
I have also added the possibility to show a badge as part of the icon representing some status of the record. For example, for consents, a green badge icon shows that the consent was given and a red badge icon shows that the consent was removed.
Here's an example of how the data from the apex class looks like, along with the badge icon: