function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kevin WilliamsKevin Williams 

Trying to create lwc to display toast message when standard page record changes.

I am trying to create a Lightning Web Component that I can put on the standard Account page and have a custom toast message displayed every time the page is edited.   The LWC would not have any UI.  It would be hidden and respond to the record update event from the standard page.
I was able to do something similar with aura using this example: http://www.sfdcpanda.com/custom-user-message-in-standard-lightning-page/
But this example didn't work quite right.  It only seemed to fire when you edited the page through the edit button.  If you edited a field by clicking the pencil on the field it didn't fire the event.
So I am trying to do the equivalent with LWC in hopes that it will work correctly from either edit method.
Any help would be appreciated.

ANUTEJANUTEJ (Salesforce Developers) 
Hi Kevin,

I am not sure if this would be possible but just a small thought will it not be possible to fire the toast message on save button instead of edit button?

Regards,
Anutej
sachinarorasfsachinarorasf
Hi Kevin Williams,

Please go through the following link for showing the toast related information.

https://rajvakati.com/2019/02/02/lightning-web-components-toast-messages/

https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.use_toast

https://newstechnologystuff.com/2019/03/16/custom-toast-component-in-lightning-web-components/

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Sachin Arora
www.sachinsf.com
Kevin WilliamsKevin Williams
Thanks for the input and the links.  The issue is that I can't figure out how to capture the event of the standard page being edited.
All the toast examples use events that are tied to the user editing a field or clicking a button on the lwc.
My lwc does not have any UI so there wouldn't be anything like -
<lightning-input label="Title" value={_title} onchange={titleChange}></lightning-input>
<lightning-button label="Show Notification" onclick={showNotification}></lightning-button>

Aura handles it with <force:recordData recordUpdated="{!c.handleRecordUpdated}"
This works even if the aura lightning component has no UI controls
But even this only works when you click the Edit button.  It does not fire for inline edit.

On save would work as well, but again, I can't figure out how to have my lwc recognize that the parent (standard page) is being saved.

Thanks,

Kevin.