Salesforce Fact #926 | Close custom action popup in Dispatcher Console

How to close a custom action modal from a Visualforce page inside the Field Service Dispatcher Console using postMessage.

Quick tip: Close a custom action modal in the Dispatcher Console

If you build custom actions for Salesforce Field Service and open them as modals (Lightbox) from the Dispatcher Console using a Visualforce page, you might need a way to close that modal programmatically from the page content. The Dispatcher Console listens for a postMessage event named closeLightbox. Posting this message from the VF page will close the modal.

How it works

In a Visualforce page running inside the Dispatcher Console lightbox, call:

parent.postMessage('closeLightbox', '*');

This sends a cross-window message to the parent Dispatcher Console frame. The console handles the event and closes the lightbox.

Reference

Salesforce Developer documentation: Dispatcher Console code samples

When to use

  • When a Visualforce-based custom action finishes its work and needs to close the modal.
  • When you want to close the modal after a save, navigation, or any custom logic.

Best practices

  • Prefer using the postMessage method over window.close() because the VF page doesn’t own the parent frame.
  • Only send the exact event name expected by the Dispatcher Console (closeLightbox).
  • Validate other required actions (e.g., saving records) before closing the modal.

Why this matters: Closing modals reliably improves user experience for dispatchers and avoids leaving orphaned lightboxes open.