I have a vf page in which I have embedded a lightning component ( lightning out ). I'm having a lightning button called "Save". On clicking this, I need to close the sub tab ( currently I'm displaying this component in console application).

I don't have a clue to how to proceed this as I'm completely stuck.

Please help me out with this.

  • Its Classic Console or lightning console? – Pranay Jaiswal Feb 5 at 19:11
  • Classic Console – uma451 Feb 5 at 19:14

In order to close a tab in the classic console, you have to use Salesforce Console Integration Toolkit. The toolkit contains closeTab() that allows you to close the tab.

The challenge here is you can only use Salesforce Console Integration Toolkit from VF page and not lightning component. So you have to find a way for your VF page to close tab.

To communicate between lightning component inside a VF page we use Window.postMessage.

So when save is completed, you have to post a message from lightning component to VF page. The VF page will have a listener to it, and you will then call closeTab() method for SF toolkit to close the current tab.

I havent personally tried it, but in theory it should work.

  • Thank you so much Pranay for your idea for me to proceed atleast. Do I need to have my visualforce page to be embedded in iframe in order to communicate from lightning to vf ? – uma451 Feb 6 at 6:30

I finally did this by creating a lightning event and calling vf page via that event. Please refer the below link for reference.

Communicate to VF page from Lightning component and vice-versa

Special thanks to Pranay !!!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.