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
Li LeeLi Lee 

lightning:overlayLib show error when run in Visualforce Page

Hi all, 

I want to show a Modal dialog in my aura component, and I find document in Lightning Component Library, here is the link: https://developer.salesforce.com/docs/component-library/bundle/lightning:overlayLibrary/documentation
I follow the code under Display Modal topic. My code as follow: 
Lightning Application
<aura:application extends="ltng:outApp" > <aura:dependency resource="c:ModalComponent"/> </aura:application>
Lightning Component ModalComponent
<aura:component> <lightning:overlayLibrary aura:id="overlayLib"/> <lightning:button name="modal" label="Show Modal" onclick="{!c.handleShowModal}"/> </aura:component>
ModalComponentController.js
({ handleShowModal: function(component, evt, helper) { var modalBody; $A.createComponent("c:modalContent", {}, function(content, status) { if (status === "SUCCESS") { modalBody = content; component.find('overlayLib').showCustomModal({ header: "Application Confirmation", body: modalBody, showCloseButton: true, cssClass: "mymodal", closeCallback: function() { alert('You closed the alert!'); } }) } }); } })
Lightning Component modalContent
<aura:component> <lightning:icon size="medium" iconName="action:approval" alternativeText="Approved" /> Your application has been approved. </aura:component>
Visualforce Page to embed lightning
$Lightning.use("c:TestModalDialog", function() { $Lightning.createComponent("c:ModalComponent", {}, "flow-component-container"); });
But when I check Button it show follow error in Browser console.

User-added image
Please corrected me if my code is wrong and may I ask for any idea how to fixed this? 
 
Best Answer chosen by Li Lee
AnudeepAnudeep (Salesforce Developers) 
Hi Lee, 

There appears to be no issue with your code. However, I feel that the error you are seeing is very similar to what is described in this post

It should work fine if you remove VF out of the equation based on the explanation below

lightning:notificationsLibrary is not supported in Lightning Out (e.g. in a Visualforce page). Please review the documentation for this component. You'll need to use an alternative component to display modals in Visualforce, such as an open-source modal component.

Let me know if this helps, if it does, please mark this answer as best so that others facing the same issue will find this information useful. Thank you

All Answers

AnudeepAnudeep (Salesforce Developers) 
Hi Lee, 

There appears to be no issue with your code. However, I feel that the error you are seeing is very similar to what is described in this post

It should work fine if you remove VF out of the equation based on the explanation below

lightning:notificationsLibrary is not supported in Lightning Out (e.g. in a Visualforce page). Please review the documentation for this component. You'll need to use an alternative component to display modals in Visualforce, such as an open-source modal component.

Let me know if this helps, if it does, please mark this answer as best so that others facing the same issue will find this information useful. Thank you
This was selected as the best answer
Li LeeLi Lee
Hi Anudeep,

Thanks for your information.