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
Joseph Simpson 7Joseph Simpson 7 

How to display an LWC Toast Message conditionally after save.

Hello. I'm a new LWC developer and need some assistance if possible.

I have a requirement to fire a toast message after a user changes a picklist field value in the record detail of an Opportunity and clicks save. I created the toast in LWC but don't know how to fire it upon save when this condition is met.

There is a lot of great information on how to fire toast messages upon a button click or when a field value is changed within an LWC. However, I can't find anything on how to fire the toast when a user makes a change in the standard record detail page and saves. Is there an if/then statement in the javascript that can be used or conditional rendering in the html? I need the toast to appear any time this picklist field value is changed and the record saved. Thanks so much!
Best Answer chosen by Joseph Simpson 7
Jaya Karthik  karnatiJaya Karthik karnati
Hi Joseph ,

Your question is quite similar to : https://developer.salesforce.com/forums/?id=9062I000000DLHqQAO , you can try anyone of the 2 solutions mentioned in the link.

Or in LWC wire you can query last modified filed and if the last modified is in minute difference is less than 1 , then you can show the logic for toast message.

Hope this helps. 

Thanks,
karthik

All Answers

Jaya Karthik  karnatiJaya Karthik karnati
Hi Joseph ,

Your question is quite similar to : https://developer.salesforce.com/forums/?id=9062I000000DLHqQAO , you can try anyone of the 2 solutions mentioned in the link.

Or in LWC wire you can query last modified filed and if the last modified is in minute difference is less than 1 , then you can show the logic for toast message.

Hope this helps. 

Thanks,
karthik
This was selected as the best answer
Joseph Simpson 7Joseph Simpson 7
This is super helpful, Karthik! Really appreciate the time. I'm reviewing that post and will give it a try. Have a great one.
Jaya Karthik  karnatiJaya Karthik karnati
Hi Joseph ,

Great to hear that it helped :) , kindly mark the previous comment as best answer so the question can be close.

Thanks,
Karthik