Tuesday, September 19, 2017

[Salesforce / Lightning] Trigger automatic Lightning Quick Action popup close

Few days ago my #AwesomeAdmin buddy Tom Blamire asked me:

"Do you know if I can automatically close a Quick Action popup window after triggering an action that does not require a UI (like downloading something from a Visualforce page)?"

The flow was simple as he asked me: click on a quick action on a standard layout page (with Lightning Experience enabled), trigger something (that can be a call to a Visualforce page or simply a backend elaboration from Apex) and close automatically the popup.

This is the solution: in this case the setTimeout() call was necessary because you need to get a bit "asynchronous", but if you make an Apex controller callback, you don't need it.

Thanks to Salesforce Lightning framework it is easy as it seem: