I need to fire a modal popup, when a specific change happens to an Opportunity. For example if the Opportunity field "StageName" changes to a specific value, i want a popup to show. I do not want the popup to show every time on pageload for example, but only that one time the record changes. I have tried to accomplish this with onChange events, but it does not seem to work for me. Any ideas how this can be accomplished?
1 Answer
You could create a platform event. Fire that event from opportunity trigger when stage changes. Subscribe to platform event in your component. Be sure to pass updated recordId in event, that way you can check in your lwc if record it is currently on has changed, if you do not check for this it would open for all users currently looking at opportunity records.
Info on publishing platform events: Publish Events in Apex
-
Thanks for you comment Stefan. I was hoping there was a more straight forward way, without the need of creating triggers and platform events. Something that could be done directly in the lwc. Commented Sep 22, 2022 at 14:56
-
1It can be done with change data capture events also, without creating custom platform event. Example Commented Sep 23, 2022 at 9:47