timeline-lwc icon indicating copy to clipboard operation
timeline-lwc copied to clipboard

Added a way to present timeline data using an Apex class

Open gmodica opened this issue 4 years ago • 1 comments

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:

timelineWithApexData

gmodica avatar Feb 04 '21 09:02 gmodica

Thanks @gmodica. This is a super interesting and innovative use case! Give me some time to review what you've done and I'll get back to you. Grateful you took the time to share this with the community. Thank you.

deejay-hub avatar Feb 05 '21 09:02 deejay-hub