Easily Toggle Standard Page Override Using a Bookmarklet

What It Does

This is a bookmarklet that makes it easy to view a standard detail page that is normally overridden by a visualforce page.  I have found this useful because it makes it easier to access the Edit Page Layout link of the standard detail page.  In a few scenarios, I have overridden a standard page only for the purpose of including custom related lists.  The standard detail section is still shown which follows the established page layouts and the easiest way to customize the detail section is still using the Edit Page Layout link.

Make this the URL of your bookmark:

javascript:(function(){if(document.location.pathname.indexOf("/apex/")==0){var id=/(\?|&)id=([a-zA-Z0-9]+)/.exec(document.location.search)[2];document.location="/"+id+"?nooverride=1";}else{document.location=document.location.pathname;}})();

How It Works

An overridden page looks like the URL below with the id being specified as a querystring.

/apex/Account?id=0016000000N1OWK&sfdc.override=1

To view the standard page you must make the URL the following:

/0016000000N1OWK?nooverride=1

Below is the javascript in the bookmarklet:

if (document.location.pathname.indexOf("/apex/") == 0)
{
  //get id from querystring and force nooverride mode
  var id = /(\?|&)id=([a-zA-Z0-9]+)/.exec(document.location.search)[2];
  document.location = "/"+id+"?nooverride=1";
}
else
{
  document.location = document.location.pathname; //strip off search
}
Advertisements
Leave a comment

5 Comments

  1. Any way that you know of to reference the Object ID for custom objects in a bookmarklet?

    Reply
    • Kyle Peterson

       /  July 31, 2012

      I don’t understand the issue you are working on. Do you want to share some example URLs and clarify what you want to grab from them?

      Reply
      • I’m probably a little off base but is there any way to either A.| run a SOQL query and return the results using javascript inside of a bookmarklet? (ex: SELECT ID FROM Account where Name = XYZ Corp. and then use that ID inside of the bookmarklet) B.| Simply merge a field from a given page into a bookmarklet?

      • Kyle Peterson

         /  August 4, 2012

        You can use a bookmarklet to grab content from the page and do things with it if that’s what you’re referring to.

  1. Force.com From Around the Web: May 5, 2012

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: