How to Force a Refresh of the Einstein Next Best Action Component

Thank you for reading this post, don't forget to subscribe!

User Question: “Hi folks, is there a way to force a refresh of the Einstein Next Best Action component in the service console? I tried re-executing my recommendation strategy flow, but the recommendation didn’t change, even though the flow picked a new one. I also triggered the lightning:nextBestActionsRefresh event from an Aura component, but that didn’t work either.”


Triggering a Refresh of the Einstein Next Best Action (NBA) Component

Einstein Next Best Action (NBA) is designed to react dynamically to changes in Salesforce, updating its recommendations. While refreshing the entire page works, there are more efficient methods to trigger a refresh in a more subtle, automatic way.

Trigger 1: Automatic Refresh Based on Record Changes If a field on the record is modified, the NBA component automatically refreshes to show updated recommendations.

Trigger 2: Refresh Triggered by Flow on the Same Page NBA also refreshes if a flow changes a related object. For example, if a flow modifies a related Survey record, the NBA component on the current record page will refresh. This smart refresh is facilitated by Salesforce’s Lightning cache, though it may not apply in all scenarios.

Trigger 3: Community Cloud Event Integrations NBA can refresh via special event integrations in Salesforce Community Cloud pages.

Trigger 4: Using a Lightning Component on the Same Page The NBA component listens for the lightning:nextBestActionsRefresh event. When triggered, it sends a new request to the NBA strategy execution endpoint. If the updated strategy returns new recommendations, the component refreshes automatically. This works on both Lightning Experience and Communities pages.

To fire the event from a Lightning component, add this tag:

htmlCopy code<aura:registerEvent name="refreshEvent" type="markup://lightning:nextBestActionsRefresh"/>

Make sure the event includes the correct recordId in its payload. The component will only refresh if the event’s recordId matches the current record page.

Example Code for Firing the Event:

javascriptCopy codefunction(component, event, helper) {
    var appEvt = $A.get("e.lightning:nextBestActionsRefresh");
    if (!$A.util.isEmpty(component.get("v.myRecordId"))) {
        appEvt.setParam("recordId", component.get("v.myRecordId"));
    }
    appEvt.fire();
}

Trigger 5: Flow Firing the Application Event If your flow doesn’t modify related records but you still want to refresh NBA, you can trigger the nextBestActionsRefresh event from a Lightning component on a flow screen. This will prompt NBA to refresh.

Trigger 6: Using Platform Events Platform events enable any event in Salesforce or an external system to trigger an NBA refresh. This is useful for real-time updates, like dynamically changing recommendations based on supply chain or ERP changes. One example involved updating recommendations based on customer sentiment detected during call recordings.

By implementing these methods, you can ensure the NBA component remains responsive and up-to-date across various use cases.

Related Posts
Salesforce OEM AppExchange
Salesforce OEM AppExchange

Expanding its reach beyond CRM, Salesforce.com has launched a new service called AppExchange OEM Edition, aimed at non-CRM service providers. Read more

The Salesforce Story
The Salesforce Story

In Marc Benioff's own words How did salesforce.com grow from a start up in a rented apartment into the world's Read more

Salesforce Jigsaw
Salesforce Jigsaw

Salesforce.com, a prominent figure in cloud computing, has finalized a deal to acquire Jigsaw, a wiki-style business contact database, for Read more

Health Cloud Brings Healthcare Transformation
Health Cloud Brings Healthcare Transformation

Following swiftly after last week's successful launch of Financial Services Cloud, Salesforce has announced the second installment in its series Read more