CPQ EventLWC - Platform Event Handler
When user is using our App and some asynchronous action happens e.g. Batch job finishes - user should be informed about the change of a current data.
Solution
Platform Event Handler
LWC component can be used. It displays a Toast message that enables user to refresh our custom LWC components (https://enxooteam.atlassian.net/wiki/spaces/ECPQ/pages/3069542524) and standard Salesforce layout or ignore it.
Example use case (gif)
Example
Establish communication between backend (enxCPQ__CPQ_EventLWC__e
) and frontend (Platform Event Handler
):
Frontend - place Platform Event Handler
LWC component on your page.
Backend - publish enxCPQ__CPQ_EventLWC__e
event:
Database.SaveResult dbResult = EventBus.publish(new enxCPQ__CPQ_EventLWC__e(
enxCPQ__Event_Type__c = 'REFRESH_PAGE',
enxCPQ__Source_Id__c = quote.Id
));
if(!dbResult.isSuccess()) {
// ...
}
Where:
enxCPQ__Source_Id__c
- Id of an object on which the component is placed (recordId
value)enxCPQ__Event_Type__c
-REFRESH_PAGE
enxCPQ__Event_Message__c
- custom message to display - if not provided standard message “There are some changes on the page.“ will be displayed
Refer to https://enxooteam.atlassian.net/wiki/spaces/ECPQ/pages/421855236 for proper implementation.