Free Salesforce.com Advanced Search Code

Written by ShamrockCRM on March 4, 2009 – 9:41 pm

Ok, I have decided to be kind.  Everyone saw the post about the Advanced Search tool for Salesforce.com already and loved it.  Everyone requested it and I am in a very giving mood.

This is such a great little tool.  You can’t miss out on this little bit of functionality.

This Salesforce.com code is incredibly simple and very easy to install.  This can be used on any edition of Salesforce, including Group, Professional, Enterprise and Unlimited.

1) All you need to do is create a Salesforce Home Page Component.

2) Make this component of type “HTML Area.”

3) Click the checkbox that says “Show HTML.”

4) Add this snippet of HTML into the box:

<script language="JavaScript" type="text/javascript">
    function submitSearchForm(){
        var searchField = document.getElementById('advsearchfield');
        document.advsrch.action = '/search/SearchResults?searchType=2&sen=0&setLast=1&str=' + searchField.value;
        return true;
    }
</script>
<form name="advsrch" method="post" onsubmit="return submitSearchForm();"><input class="searchTextBox" id="advsearchfield" maxlength="80" size="18" name="sbstr"> <input class="btn" value=" Go! " type="submit"></form>

5) Add this Home Page Component to your Home Page Layout.

6) Done

Wasn’t that easy?  This will now allow you to have one simple search box, remove the old complicated one and search through all custom fields.  (external identifiers are excellent!)

Let me know if you need help installing this!

tanner@shamrockcrm.com

***Updated 4/1/2009 – Thanks Mike for the Small Improvement to the Code!
***Updated 4/9/2010 – Glenn provided a nifty way to prevent the search box from stealing cursor focus here. He suggests to show an image of a search box and replacing the image on mouseover with the actual search box. You need to take the image from his link above and use the following code below:

<form
  id="searchForm"
  action="/search/SearchResults?searchType=2&sen=0&setLast=1"
  method="post"
  name="advsrch"
  onmousemove="if(getElementById('textBoxImage')) {document.getElementById('textBoxDiv').innerHTML='<input id=\'searchField\' maxlength=\'80\' name=\'sbstr\' size=\'18\' value=\'\' type=\'text\'><input value=\' Go! \' class=\'btn\' type=\'submit\'>'}">
  <div id="textBoxDiv">
    <img id="textBoxImage" src="/resource/1269872073000/TextBoxImage2">
  </div>
</form>

If you are having problems with the Javascript version, use the below plain HTML version

<form action="/search/SearchResults?searchType=2&sen=0&setLast=1" method="post" name="advsrch"><input class="searchTextBox" maxlength="80" name="sbstr" size="18" value="" type="text"> <input value=" Go! " class="btn" type="submit"></form>

Tags: , , , , , , ,
Posted in Business Analysis, S-Controls, Salesforce.com | 42 Comments »

Sidebar Javascript Manipulation of Edit Pages

Written by ShamrockCRM on December 20, 2008 – 9:18 pm

Every once and a while, I just come up with some new, fun way to manipulate Salesforce.com that I have never known was possible.

Previously, you could never put any code on the Edit page of a record for Salesforce.com.  Because of this, you could not tie events to certain actions on the edit page, you could not override fields or override lookup windows.  You were pretty much limited to editing only the Read page.  VisualForce will allow you to work with the Edit page, but it is very limiting once you implement it for the first time.

With this little project, I placed a Sidebar Component on the Home Page Component.  This uses an IFrame to link to an S-Control.  With this, I constantly detect what page the User is currently on.  If they are visiting an Opportunity page, I know this.  If they are editing an Account, the code know.  With this ability, I can use the code to play with the edit pages.

In this example, I wanted to override the lookup field to take me to another page when the lookup icon is clicked.  For my example, I just used Google, but you could use this to take you to a filtered lookup field, which Salesforce does not currently offer.  If you want to only show Contacts for a certain Account or something like that, this could do it.  It would look just the same as normal.  AMAZING!

Also in this example, I implanted a training note onto the page to give the User instructional advice about a certain field.  Also useful!

One more thing, I defaulted the lookup field with a certain value.  Can you default a lookup field in Salesforce normally?  Nope.  Possibly useful for aiding in searching.

Exciting and interesting ideas, right?

salesforce.com development

force.com developers

salesforce.com developers


Tags: , , ,
Posted in Programming, S-Controls, Salesforce.com, Web Development | 5 Comments »