function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Created a Simplified Search option on left-sidebar to replace new Global Search

Hi everyone,
I actually built a "simplified search" option for our sidebar, and our teams love it!  It is a combination of a visualforce page and javascript. Follow the 4 steps below to do the same.  Hope this helps!

1) Create a Visualforce page called "advancedsearch"
2) Use the following code as your page (Hint: for the "&sen=" portions in bold, these identify the objects you want to search.  For example, &sen=001 is an Account (click on the Accounts tab, and you will see those three numbers in the hyperlink).  My code below searches: Accounts, Opps, Contacts, Leads, and Campaigns

<apex:page showHeader="false" sidebar="false">
<apex:pageBlock >
<b>Enter search term: </b>
<apex:form >
function doSearch()
    var searchStr = document.getElementById('txtSearch').value;'/_ui/common/search/client/ui/UnifiedSearchResults?sen=001&sen=003&sen=00Q&sen=006&sen=701&str=' + encodeURIComponent(searchStr), "_parent" );
<input type="text" id="txtSearch"/>
<input type="button" value="Go!" id="btnSearch" onclick="doSearch()"/>
(<strong>NOTE:</strong> Only searches Accounts, Opps, Contacts, Leads, and Campaigns)

3) Finally, go to setup > customize > home > home page components.  Create a new HTML area left sidebar component.  On the screen where you can enter in the HTML, make sure you select the checkbox "Show HTML" and then paste the following (this references your visualforce page and displays it in the sidebar):

<IFRAME height=150 src="/apex/advancedsearch?core.apexpages.devmode.url=1" frameBorder=0 width="100%"></IFRAME>

4) Add the custom component to your pagelayouts and test it out! 


this is cool!  you should totally post this on the new Cookbook site.

Chrissy my users say a huge THANK YOU for this! I used yours as a base and created a "Quick Search" sidebar including the product-specific search they missed most of all. I can't tell you the complaints I got about the new search and this custom snippet is fantastic. Pretty bad to have to create something custom to work around a new feature though, I don't think Salesforce vetted the new search enough. It definitely hurts productivity for high volume users. Thanks again!
Something a little unusual. This works great in IE8 and FF3x, but in Chrome (which I use) I got a redirect loop error. Apparently Chrome doesn't like stepping from to within an iframe without a full URL. There's a known bug in Chrome behind this, but it's been open for months without resolution. When I changed the src attribute to the full URL (, Chrome displayed the iframe properly.

How do you make it where it will search when you press enter? It only searches if you click it.


Getting it to work when pressing enter means making a submit button within a form, but I had to go further because the behavior is different between IE, Firefox and Chrome.  This finally worked for me across all browsers.  I still have trouble with Chrome displaying redirect loops, but I can deal with that since I'm the only one using it.



<apex:page showHeader="false" sidebar="false">
		function search1() {
			var searchStr1 = document.getElementById('txt1').value + '*';'/_ui/common/search/client/ui/UnifiedSearchResults?sen=001&sen=003&sen=006&sen=701&sen=a0G&str=' + encodeURIComponent(searchStr1), "_parent" );
		function pressedKey1() {
			if(event.keyCode==13) {
	<apex:form id="generalsearch" onsubmit="search1();" onkeypress="pressedKey1();">
		<apex:pageBlock >
			<b>General: </b>
			<input type="text" id="txt1"/>
			<input type="submit" value="Go!" id="btnSearch1" name="btnSearch1"/>




this is a great solution. for my sales guys just doing acct and contacts in that sidebar, and it adds the * so the partial works, is awesome. thanks!

Andy KellerAndy Keller

I followed the directions but get this message when I submit the search:


URL No Longer Exists
You have attempted to reach a URL that no longer exists on

You may have reached this page after clicking on a direct link into the application. This direct link might be:
• A bookmark to a particular page, such as a report or view
• A link to a particular page in the Custom Links section of your Home Tab, or a Custom Link
• A link to a particular page in your email templates

If you reached this page through a bookmark, you are probably trying to access something that has moved. Please update your bookmark.

If you reached this page through any of the other direct links listed above, please notify your administrator to update the link.

If you reached this page through a link on our site, please report the broken link directly to our Support Team and we will fix it promptly. Please indicate the page you were on when you clicked the link as well as any other related information. We apologize for the inconvenience.

Thank you again for your patience and assistance. And thanks for using!

OK the


part of the code is telling it what objects to look in, but how do you know what objects have what numbers?


If you click on a tab in SFDC, you will see the object numbers in the hyperlink.


For example, if you click on the Accounts tab, the hyperlink will read:

Thus, to search in Accounts, use "001".


I have recieved the same URL No Longer Exists when I copied and pasted this in creating the page, can someone let me know why?


I have followed the directions but all I get in the tab on the left is the html code.  I am not allowed to click on anything since it did not recognize the Home Page Component script.  I have tested in both Chrome and IE 9.  Is there also anyway to restrict the search to a custom field within an account?



~Onkar~Onkar'/_ui/common/search/client/ui/UnifiedSearchResults?sen=001&sen=003&sen=006&sen=701&sen=a0G&str=' + encodeURIComponent(searchStr1), "_parent" );

Relace this line with'/_ui/search/ui/UnifiedSearchResults?sen=001&sen=003&sen=006&sen=701&sen=a0G&str=' + encodeURIComponent(searchStr1), "_parent" );


Adam LedermanAdam Lederman
Thank you!  I recently found out my Hack to create a text entry "search" to a report wasn't working right.

After many attempts, I came accross this article.  I made a very simple modification to the code, replacing the:'[linktoreport?pv0=' ...

It worked!  so thank you.