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?", "answerCount": 5, "upvoteCount": 0, "datePublished": "2018-10-05T13:09:08.000Z", "author": { "@type": "Person", "name": "Adam Drissel", "url": "https://trailblazers.salesforce.com/profileView?u=0053A00000DXrjoQAD", "affiliation": { "@type": "Organization", "name": "Blue Cross North Carolina" } }, "suggestedAnswer": [ { "@type": "Answer", "text": "@knght4yshua, were you able to get this issue resolved? I am facing the same issue. I am not able to close the sub-tab. I tried implementing window.close(); - 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?", "upvoteCount": 0, "url": "https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007T4HO4SAN", "datePublished": "2019-09-06T07:44:14.000Z", "author": { "@type": "Person", "name": "Jigar Trivedi", "url": "https://trailblazers.salesforce.com/profileView?u=0053000000BK9F7AAL", "affiliation": { "@type": "Organization", "name": "LogicRain Technologies Pvt. Ltd" } } } ] } }
Skip to main content

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:

<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?
답변 5개
  1. 2019년 9월 6일 오전 7:44

    @knght4yshua, were you able to get this issue resolved? I am facing the same issue. I am not able to close the sub-tab. I tried implementing

    window.close();

    - 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?
0/9000