6

One of SObject Lightning pages contains an Action Button which opens a custom Visualforce page. How can I close it in other way than clicking the 'X' button?

So far I've tried:

window.close(), window.top.close(), window.self.clse(), $A.get("e.force:closeQuickAction").fire(); and window.top.location.href="/{!$CurrentPage.parameters.id}" - none of these worked.

So far, an option closest to the solution was usage of window.top.location.href="/{!$CurrentPage.parameters.id}" but it refreshes the whole window.

I was hoping the $A.get("e.force:closeQuickAction").fire(); line will do the trick, but I'm receiving $A is nod defined error, even if I use <apex:useLightning/> tag.

1 Answer 1

11

I've eventually found a solution. The following script has to be included:

<script type='text/javascript' src='/canvas/sdk/js/publisher.js'></script>

Then use this line to close the Quick Action window:

Sfdc.canvas.publisher.publish({ name: "publisher.close", payload:{ refresh: "true" }});

2
  • Awesome!! Why is this so poorly documented!? Commented Sep 3, 2019 at 18:50
  • 1
    Well, looks kinda like a hack so I can understand why they didn't included it explicitly anywhere in the documentation. Commented Sep 9, 2019 at 8:43

You must log in to answer this question.

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