You need to sign in to do that
Don't have an account?
knght4yshua
I need to refresh the parent page that a Lightning Component was launched from
I have created a custom button on a custom object. The button, when clicked, opens up a Visualforce Page, in which the Lightning Component is placed:
The component (for which I cannot post the code, sorry) consists of a Lightning Design System modal, with a lightning:recordEditForm inside of it. Once the form is filled out and saved, the Apex controller creates a related record and passes a success/fail boolean to the Lightning Helper.
In the Helper I have the code written to show a Toast and automatically close the window after a timeout:
Now, the window itself closes just fine. However, I need something else to happen as well. I need the record on which the button was pushed to refresh/reload. I've tried many different Javascript methods, but the one I think may work is prohibited by lightning (uses the "opener" syntax).
Is there any way to do this?
<apex:page docType="html-5.0" standardController="Business_Request__c" extensions="BusinessRequest_BRtoCaseController" showHeader="false" sidebar="false" standardStylesheets="false"> <apex:stylesheet value="{!URLFOR($Resource.SLDS260, '/styles/salesforce-lightning-design-system.min.css')}"/> <apex:includeScript value="{!$Resource.jQuery331}"/> <apex:includeLightning /> <apex:outputPanel layout="block"> <div id="lightning"/> </apex:outputPanel> <!--Lightning Component--> <script> var base = location.protocol+"//"+location.hostname+(location.port && ":"+location.port); var brRecordId = "{!recordId}"; $Lightning.use("c:BusinessRequest_BRtoCaseDependencyApp", function() { $Lightning.createComponent("c:BusinessRequest_BRtoCase", { recordId : brRecordId, baseUrl : base }, "lightning", function(component) { }); }); </script> </apex:page>
The component (for which I cannot post the code, sorry) consists of a Lightning Design System modal, with a lightning:recordEditForm inside of it. Once the form is filled out and saved, the Apex controller creates a related record and passes a success/fail boolean to the Lightning Helper.
In the Helper I have the code written to show a Toast and automatically close the window after a timeout:
action.setCallback(this, function(response){ var state = response.getState(); var caseCreated = Object.keys(response.getReturnValue())[0]; var caseComCreated = Object.values(response.getReturnValue())[0]; if(state === "SUCCESS" && caseCreated === "true" && caseComCreated === "true") { $A.util.addClass(component.find("messageType"),"slds-theme_success"); $A.util.removeClass(component.find("successIcon"),"slds-hide"); $A.util.removeClass(component.find("successMessage"),"slds-hide"); this.showToastHp(component, true); } } (later in the code...) showToastHp : function (component, success){ var $j = jQuery.noConflict(); if(success){ $j("#toastDiv").addClass('slds-show'); $j("#toastDiv").removeClass('slds-hide'); } else{ $j("#toastDiv").addClass('slds-hide'); $j("#toastDiv").removeClass('slds-show'); } } setTimeout(function(){ window.close(); },4500); }
Now, the window itself closes just fine. However, I need something else to happen as well. I need the record on which the button was pushed to refresh/reload. I've tried many different Javascript methods, but the one I think may work is prohibited by lightning (uses the "opener" syntax).
Is there any way to do this?
- which you have used here - to close the tab. However, it is also not working. Do you know how we can close the tab and reload the parent page?