Is there a way to apply Maintenance page for Salesforce Application? We want to restrict Users to access Sandboxes when Refresh is going on and Production when Major Releases/Data operations are performed.


  • 1
    You can do this by restricting the login hours of the profiles to prevent them accessing the relevant instance. The only profile to exclude is the System Administrator so you can still get in to limit access to production.
    – Dave Humm
    Oct 19 '20 at 11:57
  • In that case, users will get error while accessing Salesforce. Is there not a way to share a static HTML page with them with a message ? Oct 19 '20 at 12:21

This looks like an interesting use case. Though I have never done this personally, you can see if the following works for you.

  1. Create a Visualforce page, which acts as your page that shows maintenance message.

  2. Create a LoginFlow that consumes this Visualforce page. The login flow will be called for every login for the applicable profiles.

  3. Create an Apex class that will be called when the Visualforce page is loading. The logic within the class needs to be something like below:

    ApplicationReadWriteMode mode = System.getApplicationReadWriteMode();
    if (mode == ApplicationReadWriteMode.READ_ONLY) {
      // redirect to maintenance page
    } else if (mode == ApplicationReadWriteMode.DEFAULT) {
       if(valueFromCustomSettingOrCustomMetadata == 'SANDBOX REFRESH') {
         // redirect to maintenance page and force logout
       // allow successful login

For Sandbox refresh part, I have assumed you need to have a custom setting or a custom metadata that tells the Login Flow to redirect to the maintenance page.

Note: Don't assign the login flow to System Admins and the logic will not be executed for them.

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