[SalesForce] how to refresh the Lightning record page when we edit and save record

I have created tabs in the lightning record page. I have given inline VF pages as tabs in a lightning record page. I need to refresh automatically when we edit the record in lightning. Currently, inline vf page is not refreshing automatically. we are refreshing URL then Inline VF page is Updating. Is there any configuration setting to refresh the lighting record page when we edit the lighting record page?

Best Answer

Why not create a lightning component and put your VF inside it as an iframe?

You lightning component will listen to refreshView event which is fired when some data on lightning changes? It will reload the page.

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >

    <aura:attribute type="String" name="VFPagName" default="MyAccountPage"></aura:attribute>

    <aura:attribute name="src" default="#" type="String"></aura:attribute>

     <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
     <aura:handler event="force:refreshView" action="{!c.doReload}"/>

    <iframe src="{!v.src}" aura:id="myIframe"></iframe> 
</aura:component>

JS:

({


    doInit : function(component, event, helper) {
        var vfPageName = component.get("v.VFPagName");

        component.set("v.src",'/apex/'+vfPageName+'?id='+component.get('v.recordId'));

    },


    doReload : function(component,event,helper){
        var srcBackup = component.get("v.src");   
        component.set("v.src","#");
        component.set("v.src",srcBackup);

    }
})

Also dont find to add the design file so that you provide the pageName and extra params from app builder.

Design:

  <design:component>
        <design:attribute name="VFPagName" label="Your VF Page Name" />
    </design:component>
Related Topic