Posted on October 31st, 2008 1 comment
This post isn’t anything ground breaking or new but I remember the first time I tried to do this! Also every time I do it I always forget something
The requirement here is simple
Create a form that allows the user to enter some search criteria and have it search across specific, multiple columns
There may be a Customers list (which may not be too different to the Northwind database in Access 2007…wink, wink). This list holds lots of details including the customers name, address, phone number, post code, current balance, account number
When the customer calls you need to be able to call up their details quickly. To identify the customer you may ask for an account number, a post code, etc (even just a part of that information – first three digits of their post code for example) which is why this needs to work across multiple columns
You may be thinking “why don’t you just use the built-in search functionality?”
The built-in search functionality in SharePoint is still a great tool (and we’ll leave Search Server Express out of this for now!) but the main problem in this scenario it doesn’t work as we as I only want to search on specific fields
So to get this running first create a Web Part Page
Click “site actions”, “create”, “Web part page”
Enter a name for your page (We’ll use “customer search” here), select a layout template and select a document library to store the page in and click OK
Once you’ve done that you will be taken to the new page. It will be in edit mode ready for you to add some web parts!
Click “Add a web part”, select a “Form Web Part” and click OK
If you just wanted to search on one specific column you could add your list to the page, setup a web part connection and never have to touch SharePoint designer!
But why do things the easy way?
Open SharePoint Designer, then open your site and then open your Customer Search Web Part page (if you want to take a copy of that file, now is the time to do it before we mess with it!)
Click on the “Data View” menu and select “Insert Data View”. The data source task library task pane will open and ask you to choose a list.
Select your customer list and click “Show Data”
Hold down your CTRL button and pick some fields. I’m going to pick
First Name, Last Name, Company, Business Phone and Zip/Postal Code
Then click the “Insert Selected Fields as” menu and select the “Multiple Item View” option
The data view will then be inserted into your page.
Click the > button for the data view so you get the common tasks menu and select the “parameters” option. In the Data View Parameters dialog select “New Parameter”
Give your parameter a name (i’m using “SearchValue”) and change the parameter source to CONTROL and the CONTROL ID to the ID of your FORM WEB PART (If your following these instructions or haven’t changed the ID it’s more than likely T1) and click OK
Then, from the command task menu of the data view select “Web Part Connections”. In the first page of the wizard select the “Get Parameters From” option.
On the second page leave the default “connect to a web part on this page” option selected
On the third page set the target web part to be form web part and the target action as “Provide form values to”
On the fourth page look for your previously created parameter on the right and match this up with your form web part ID
On the final page click finish
The last thing to do is to tell the data view to apply the filter. On the common tasks menu select the FILTER option
Add as many clauses as you need to customise how your search works. You can even work with fields that aren’t actually displayed
My example looks for text that contains my search criteria in any fields (using the OR option)
Remember to pick your previously created parameter as your value
Save the page!
Go to the page using your browser and test it out
Other things you may want to go and change on the common tasks menu include the sort order and the amount of items displayed per page
Finally, what point is there in displaying a limited set of fields if we can’t drill into the full record?
On the common tasks view click “Show Example Data”
Click on the one of the fields you want to have as your link and change the format as option to HYPERLINK
Select “Hyperlink Options”
Build the Address field so that it looks similar to the example below
There may be a better way of doing this but it works for me. If you know of a better way please let me know!
You can also change DispForm to EditForm if you want to be able to go straight to editing the record
Keep an eye on the “Text to display field” as this tries to mirror the address field and this isn’t always what you want
Save the page again and marvel at your finished project!
The northwind demo data is a bit pants for testing this to be honest but it does the job
As you know the latest version of SharePoint (v3 / 2007) is going to be a part of SBS 2008 and there is a lot of potential for helping your clients make the most of the product so get learning!Andy Parkes is Technical Director at Coventry based IT support company IBIT Solutions. He is also Microsoft Partner Area Lead for 2012-2013 and coordinates AMITPRO which is a peer group for IT Professionals in the Midlands area. He also isn't a fan of describing himself in the third person.
One Response to “Creating a multi-column search form in SharePoint v3 with SharePoint Designer”
Watsa Chaodee January 28th, 2013 at 10:33 pm
This is really great. I had tried many options until I found this article. This is the best and simplest solution. Good for a SharePoint newbie like me. Thanks again.
Leave a Reply