force:editRecord event works fine in my lightning app, but the same does not work in the visual force page. I am aware that force:editRecord is handled by one app container but I am looking for work around here like using $A.eventService.addHandler.

Visualforce page

<apex:page showheader="false" sidebar="false" standardStylesheets="false">


            <apex:includeLightning />
            <div id="lightning"/>

            var myUserContext = "{!$User.UITheme}";
            $Lightning.use("c:TestApp", function() {
                                           function(cmp) {
                                                   handler: function(event { 
                                var message=
                                         {type: "EventFromVF",                                                                 
                                    message: event.getParams().recordId};

                                   parent.postMessage(message, lexOrigin);



lightning source from edit record being called
edit:function(component, event, helper) {
            var editRecordEvent = $A.get("e.force:editRecord");
            editRecordEvent.setParams({"recordId": component.get("v.record.Id")});

Listener controller and component

<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
    <aura:attribute name="vfHost" type="String"
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <iframe aura:id="vfFrame" src="{!'https://' + v.vfHost + '/apex/xyzpage'}" />

    doInit : function(component) {
        console.log('hello listener');
        var vfOrigin = "https://" + component.get("v.vfHost");
        window.addEventListener("message", function(event) {
            if ( (event.data.type) && (event.data.type=='EventFromVF') )
            if (event.origin !== vfOrigin) {
                // Not the expected origin: Reject the message!

            // Handle the message
            var toastEvent = $A.get('e.force:editRecord');
                recordId: event.data.message

        }, false);


lightning application TestApp

<aura:application extends="ltng:outApp"  access="GLOBAL" >    
    <aura:dependency resource="c:xyz" />
    <aura:dependency resource="markup://force:editRecord" type="EVENT"/>
  • 1
    It's not clear exactly what you're trying to do. Adding specificity to your question and including representative extracts of the code you're working on may help produce a solution.
    – David Reed
    Commented Aug 14, 2018 at 13:33
  • Hi David, thanks for your response. Actually, I have used force:editRecord event in my lightning component and the event works as expected if I use the component in my lightning application but when I am using that component in my visual force page that event is not getting fired which works fine from the lightning application.force:editRecord is handled by one app container but I am looking for work around to make it work inside visual force page,hope this makes it clear, let me know if it is still not clear Commented Aug 14, 2018 at 13:39
  • I believe it would be pertinent for you to include how you are trying to make it work in Visualforce
    – glls
    Commented Aug 14, 2018 at 13:53
  • 1
    Hi glls, thanks for your input. please check now i have shared the code Commented Aug 14, 2018 at 14:15

1 Answer 1


e.force:editRecord is not supported from VisualForce using lightning out - you can see from the documentation - at the bottom of the page:

This event is handled by the one.app container. It’s supported in Lightning Experience, the Salesforce app, and Lightning communities.

That means it is not supported from lightning out as you are trying to use it

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .