Reply
Regular Contributor
Jager
Posts: 83
Accepted Solution

Customizable Search HTML Components

[ Edited ]

 Occasionally, people have requested to have more flexibility in how search works on the homepage. Usually "Advanced Search" will solve most needs (searching customfields, etc)...however this solution may be interesting to you if you'relooking for more control and to do things like:


1) Sort Search Results
2) Search for Contacts within specific Accounts
3) Search specific fields rather than all fields
4) Bypass the search indexing of records ensuring that newly created records are always immediately available.

 

Below are instructions for salesforce.com administrators on how to create a custom HTML component for searching. This uses our report engine, HTML Components on thehomepage, and Javascript.

 

The user will be presented with a form which, when submitted, will pass variables to apre-defined report which will use those variables as the criteria from which tosearch. Because this utilizes our reporting functionality, users are able tosort the search results, search account fields on contacts, and search specificfields as specified in the HTML component.

 

Note: This solution is bound by the table joins that our Reporting Engine provides. In other words, if you are unable to report on all of the types of records in thesame report, you'll be unable to search them as well as this solution utilizes the reporting functionality. If this is a requirement, you would need to set upadditional HTML components to handle these different type of record searches.

 

1)      Create a "summary" report for Accounts and Contacts in the format you'd likethem displayed on your search results page. Be sure to include any fields (suchas CSP, state, etc) that you’d like to sort on.

2)      Go back to the "Select Criteria" screen and be sure the "View:"is set to "All Visible Accounts" and clear any dates in the daterange field.

3)      Under the "Advanced Filters", choose the fields that you’d like to be searched.For instance, in the first drop down box, choose "First Name", in thesecond, choose "Last Name", in the third, choose "Account Name",etc.. You can set up to 10 fields to be searched from the custom advanced search page we’ll be creating later. To add more than 5, select "Advanced Options"on the "Select Criteria" page then "Add Row" for morefilters.

4)      Set the "Operator" to "Contains" for all fields that you set.

5)      Be sure to leave the actual value in any of the "Value" fields empty.

6)      Save the report. Be sure to save the report in a publicly available folder. "Account and Contact Search" may be a good name.

7)      Now that the report is saved, go to the "Reports" list and copy the URLthat links to that particular report. This URL is unique for that report and will be used for our advanced search a bit later on.

8)      Clickon "Setup", "Customize", "Home", "Home PageComponents", and "New Custom Component".

9)      Create a name for your search component ("Account and Contact Search", forinstance) and select "HTML Area" as the type. Select "Next".

10)  Choose "Narrow" if you’d like your search to be on the left side of thescreen. Choose "Wide" if you’d like your search screen to be in the main section of the user’s home page.

11)  In the "Formatting Controls" section, select "Show HTML"

12)  In the body of the HTML, we must enter some Javascript. Essentially, this Javascript will allow the variables that are entered to be automatically passed into a URL. The URL will be the report URL for the report you created earlier (designated as REPORTURL below).  This script should be customized based on yourreport URL and the filters which you are requesting users to search on.

 

<FORM action=https://REPORTURL method=get>

FirstName: <INPUT name=pv0><BR>

LastName: <INPUT name=pv1> <BR>

Company:<INPUT name=pv2> <BR>

<INPUT type=submit value="Submit Query"> </FORM>

 

 In the example above, First Name, Last Name, and Company would be the first three filters on the "Select Criteria" of the report. As you add additional criteria,you must change the <INPUT name=pvX> to reflect the number of filter. So if you used all 10 filters, for instance, it would look like<INPUTname=pv9>.

 

13)  De-Select" Show HTML" at any time to see what your advanced search screen lookslike as you’re building it.

14)  Once completed, save your component. We must now add it to a home page layout.

15)  Click on "Setup", "Customize", "Home", "Home PageLayouts".

16)  Click on "Edit" next to the page layout that you would like to add this advanced search screen to.

17)  Put a check next to the advanced search component that you created and click"Next".

18)  Movethe search screen to where you’d like it to appear on the page and click save.

 

Your new account and contact search has been created.  This combination of HTML Components, Javascript, and reports gives you as the administrator complete control over how searches are handled within Salesforce.com.

 

UPDATE:

If you'd like a private appexchange package that will install this into your org, follow these instructions:

http://community.salesforce.com/sforce/board/message?message.uid=132372#U132372 

 

 

Message Edited by Jager on 06-12-2009 11:47 AM
Contributor
ktipton
Posts: 6

Re: Customizable Search HTML Components

This was really helpful to me, but I am now wondering if you know of any way to create this component and pass the search values to the Account Owner report. That report has a standard filter built into it for Account Name contains, so I am not sure how to pass the search criteria. I'd rather be able to perform the search from the Home page than have people go to reports for this. Can you help me?

Thanks,
Katie
Contributor
Chris P
Posts: 8

Re: Customizable Search HTML Components - Advanced Search

[ Edited ]
Thanks Jager!

I modified the code to make an Advanced Search box appear on the Home Page.

I also changed the code for the button so the salesforce.com blue search button appears (just like in sidebar search) instead of the generic HTML button.

Here's my code (replace the "(" from the beginning of each tag--the forum wouldn't let me post straight javascript):

(FORM action=https://na1.salesforce.com/srch/advsearchresults.jsp?searchType=2& method=get>

Search This: (INPUT style="BACKGROUND-COLOR: #ffffa0" name=str>

(INPUT class=button type=submit value=Search name=search>

(/FORM>

-Chris

Message Edited by Chris P on 05-23-2005 08:23 PM

Regular Contributor
RK
Posts: 52

Re: Customizable Search HTML Components

Wow...this is a great customization.

I do have a question, though.

If I were to add a "City" search box on the new form, is there a way to pass the entered text to two separate parameters in the report.

The reason I ask - we have multiple address records on each of our contacts, and I would like the report to bring back any records with the entered city on any of it's address records.

I realize that I could add multiple "City" search fields, but I don't want my users to have to enter the same city multiple times.

Anyone have any suggestions?

Thanks,
RK
Contributor
Posts: 6

Re: Customizable Search HTML Components

This works great, thanks! Is there any way to add the search component to specific tabs so it shows up beneath the regular search bar?  For example I created a component to allow for better searches of Accounts, but I want to add that component to the Account Tab sidebar...can I do this?
Contributor
Posts: 6

Re: Customizable Search HTML Components

Ok, I poked around some more in the Salesforce help pages and found a setting in Setup=>Customize=>User Interface called 'Show Custom Sidebar Components on all Pages' which makes the search component i just created appear in the sidebar on all tabs.  Still, is there any way to make this show up in only certain tabs?
Regular Contributor
Jager
Posts: 83

Re: Customizable Search HTML Components

Glad you're enjoying this component. Pretty incredible 3 years later people still are finding value in this! Good stuff!

Unfortunately there's no way to selectively show custom sidebar components based on which tab you're looking at... it's either an all or nothing scenario when you click off on the "Show Custom Sidebar Components on All Pages" checkbox.

If instead of tab based, you can have it user based... you could theoretically create a different profile which uses different sidebar components for different users... but still, the behavior on all tabs will be the same.

It's not a bad idea to have certain components show up for different tabs. I'd suggest throwing that idea on http://ideas.salesforce.com
-Jager
Visitor
dsekules
Posts: 1

Re: Customizable Search HTML Components


RK wrote:
Wow...this is a great customization.

I do have a question, though.

If I were to add a "City" search box on the new form, is there a way to pass the entered text to two separate parameters in the report.

The reason I ask - we have multiple address records on each of our contacts, and I would like the report to bring back any records with the entered city on any of it's address records.

I realize that I could add multiple "City" search fields, but I don't want my users to have to enter the same city multiple times.

Anyone have any suggestions?

Thanks,
RK


Okay, I appreciate its been _ages_ since you posted your question, RK, but since I came across the same issue and hit upon what looks like a good solution I figured I might as well share...

My solution was to create a formula field called "Full Address Text" which concatenates together all the address fields for all the addresses for (in my case) the person accounts being searched. I added some formatting and blank-line suppression 'cos I'm that kind of perfectionist, but for searching purposes that's not really necessary. All you then need to do is define the concatenated field as your "contains" criterion for the report and Bob's your uncle.

Same trick works well for telephone numbers, by the way.

I hope this helps.

David Sekules
Astadia
Regular Contributor
BenP
Posts: 146

Re: Customizable Search HTML Components - Advanced Search

[ Edited ]
I'm trying to use this custom code and it's almost working.  I was able to get the search box and button to show on the sidebar of every tab like I wanted which is great.  Problem is that when I click search I'm prompted for a password and I also need to enable the exact phrase checkbox.
 
Creating an advanced search tab could be an option too.  The idea here is to hide the standard search in the sidebar in favor of the advanced search.
 
I am using the following code
Code:
<FORM action=https://na1.salesforce.com/srch/advsearchresults.jsp—searchType=2& method=get>

Search This: <INPUT style="BACKGROUND-COLOR: #ffffa0" name=str>

<INPUT class=button type=submit value=Search name=search> 

</FORM>

 
 
Thanks for any ideas.


Message Edited by BenP on 11-10-2008 01:26 PM
Contributor
Posts: 6

Re: Customizable Search HTML Components - Advanced Search

BenP,

Are you using a custom report for your search?  By the URL in your code it looks like you are just forwarding to the Advanced Search page.  Here is the code for the component I created that worked well:

Code:
<form action="[put report url here, example: https://na5.salesforce.com/00O7...]" method="get">
Account Name: <br>
<input name="pv0"><br>
Account ID: <br>
<input name="pv1"><br>
Company Name: <br>
<input name="pv2"> <br>
<input class="button" value="Search" name="search" type="submit">
</form>

If you use a report, you need to create the report first then link to it in the component in the first line of the code.  In the search I've included you can search by Account Name, Account ID, or Company Name (or any combination thereof).  The form puts the inputted text in the first three search criteria fields of the report (in my case the first three fields correspond to the Account Name, Account ID and Company Name respectively) then runs the report.  In the report you can specify between 'contains' and 'equals' for each field.  I hope this helps.

-Jonathan