Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using a Homepage Component to make an AJAX request from the built-in "Send an Email" to a Visualforce page I have written. The Visualforce page then returns JSONP for the original page to use.

The setup is working fine in general. However, when an admin user has Development Mode enabled, Salesforce is injecting HTML (presumably the Development Mode bar) into the Visualforce page. This is breaking my JSONP and causing some browsers to crash when they request it.

I see a couple of possible solutions to this problem.

  • The ideal would be if there were some way to prevent Salesforce injecting this code into my Visualforce page, however I have not come across a way to do that.

  • Alternatively, I could use AJAX to check whether the user has Development Mode enabled, and if so, disable the call from the "Send an Email" page. But I can't find a way to check that either.

  • Finally, I could use AJAX to check whether the user is an Admin, and if so, disable the functionality on the "Send an Email" page. This is not ideal, as not all Admins will have Development Mode enabled.

I'd appreciate hearing your thoughts on any of these approaches.


share|improve this question
For the latter one, why couldn't you just create a different home page layout for admins and remove the component that is injecting JS? – James Loghry Mar 7 '14 at 13:38
up vote 4 down vote accepted

You can try to use a standard SFDC User object and a field called UserPreferencesApexPagesDeveloperMode:

When true, indicates the user has enabled developer mode for editing Visualforce pages and controllers.

(Source docs)

Something like this:

    Boolean b = [Select UserPreferencesApexPagesDeveloperMode 
                 From User 
                 Where ID = :UserInfo.getUserId() 
                 Limit 1].UserPreferencesApexPagesDeveloperMode;

AJAX-only version:

function chechDevMode() {
    var currentUser = sforce.connection.query("Select UserPreferencesApexPagesDeveloperMode From User Where Id = '{!$User.Id}'");
    var records = currentUser.getArray('records');
    alert('Dev mode on: ' + records[0].UserPreferencesApexPagesDeveloperMode);
share|improve this answer
Fantastic, that's exactly what I need. Thank you mast0r. – Rob Mar 7 '14 at 13:37
As a sidenote, Salesforce seems to be inconsistent here: the setting in My Settings > Advanced Settings is called "Development Mode", whereas the docs call it "Developer Mode". – Rob Mar 7 '14 at 13:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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