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
Ken Koellner @ EngagewareKen Koellner @ Engageware 

set error message in lightning.

I'm working on a lightning component that will run on both a quick action and in a VF page.  I know toast doesn't work when the component is in VF.  It appears showNotice() doesn't either.

Is there a prefered way to put up an error message when the component is run both from LEX and via VF?

The use case is the component does a call to an Apex aura controller and certain conditions can't be fulfilled, it returns a message.  The messasge instructs the user on what they have to fix before they resubmit.  

I considered just putting a message on a field for this specific error but it concerns a lightning:select and, unlike lighting:input, lightning:select won't let you put a custom error on it.  
VinayVinay (Salesforce Developers) 
Hi Ken,

force:showToast It doesn't say anything about classic or VF, so you have to manually implement toast using SLDS.

https://developer.salesforce.com/docs/component-library/bundle/force:showToast
https://salesforce.stackexchange.com/questions/246948/lightning-toast-message-is-not-working-in-classic

Review below link which has sample examples.

https://developer.salesforce.com/forums/?id=9060G000000MVLYQA4
http://abinashbarik.blogspot.com/2017/10/use-lightning-toast-in-visual-force-page.html
http://bobbuzzard.blogspot.com/2018/04/toast-message-from-visualforce-page.html

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,
Vinay Kumar