[SalesForce] Lightning component auto refresh to view the case record

In Detail-record page, where you can see (activityTracking page and related list) and on header of the page there is new case button to create a new case record.

I have an activityTracking page(lightning component) that display a Child object activity (Tracking of record page)details. Whenever detail page is opened, it automatically retrieve the record ID of that detail page and display those records(Activity) in activity component.

Instead of doing manual refresh, I want it to auto refresh the activityTracking page(lightning component) to view the case record by using NEW CASE button.

ActivityTrackingPage is a lightning component, where I need to write a code for auto refresh process.

Need suggestion please….

Best Answer

The only reasonable route I see here, if the process for creating a Case is not under your control, is for your Lightning component to embed the <lightning:empApi> event streaming service.

You can then either

  1. use the Streaming API to subscribe to notifications about record creation events or
  2. write an Apex trigger that implements custom logic on the creation of your Support Case records to fire a Platform Event, to which the empApi component subscribes.

Your JavaScript callback from the empApi component can then take action to refresh your activity view upon receipt of one of those events.

The only other feasible solutions I see are:

  1. Polling. I wouldn't recommend it.
  2. If and only if the data model permits - that is, if Support Case is a child object in a master-detail relationship - you could create a Roll-Up Summary Field and then use <force:recordData> to watch for change events in the parent object's roll up field, representing creation events for the child object. I think it's unlikely that that applies here.