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
Engine ForceEngine Force 

e.force:showToast

Hi I'm trying to follow the example here https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/events_one_demo_load.htm.

Atfter setting it up, I got this error when previewing it by clicking on the preview button:
Something has gone wrong. Unable to get property 'setParams' of undefined or null reference. Please try again.

I think it's the helper js "getContacts" where

var toastEvent = $A.get("e.force:showToast");
            if (state === 'SUCCESS'){
                toastEvent.setParams({
                    "title": "Success!",
                    "message": " Your contacts have been loaded successfully."
                });
            }

e.force:showToast appears to be a system function. Can someone confirm? Does this function only work on Salesforce1?
Stefania Ezquerra 1Stefania Ezquerra 1
Hi! Same thing happening to me, could you finally solve it? 
c_r_carvalhoc_r_carvalho
@Stefania Ezquerra 1 ad @Engine Force, e.force:showToast works in salesforce1 app or Salesforce Lightning Experience only, but not works in salesforce classic.

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_force_showToast.htm
Deepak Gupta 75Deepak Gupta 75
Same issues, even I was facing. But let me tell you what exactly I was trying to do.. I created a component with force:showToast.
I Called the component in the application, and was trying to see the output, And received the error.
try calling the component on Lightning Page/Lightning Record Page etc. It will work.