SharePoint 2010 Use an SPD Workflow to Build Custom Search URLs

I am currently working on a prototype for a client that will be used by various users to access common policies and procedures. One of the requirements of this solution is that if a user happens to select the wrong policy or procedure that they can easily be re-directed to the correct one. Since we don’t really know what the user was thinking when they selected the item, it might be difficult for us to know how to best redirect them. We decided that a good potential solution for this would be to utilize search. This way we can simply rely on the data currently in the system and all we need to do is develop a list of common terms that users “might” have meant when they accessed the current policy or procedure. The theory is that we will keep a list of common search terms and then whenever a user selects one of the terms they will conduct a search that returns items with that keyword. From the search results they should be able to see a wide enough selection of content that they can hopefully narrow in on the correct procedure. The list will be managed by the site owners and they can add items to the list based on feedback from the users.

Here is a quick screenshot of the home page of the prototype I am working on:


To build the solution I created a custom list called search terms with two columns- Search Term (title field) and Click on Term to Search (Rich Text Field).


Once I had the list set up I created a simple workflow in SPD that updates the Click on Search Term Field whenever the title is updated or when a new title is created. Since my field is a rich text field, I can use SPD to build a custom html string.

My workflow is associated with the Common Search Terms list and is configured to start manually, whenever an item is updated or when anything is modified.



There are only two actions for my workflow:

  • Create Variable
  • Set Field in Current Item


In the set variable action I am using the string builder to add the title of my search term to my URL.


The text that I am using above is the HTML that is going to create the hyperlink for me. The two sections highlighted below show the location that you would use to insert the title from the current item. We have also added the “target=_blank” parameter so that the search results will open in a new window. This isn’t required, however was requested in my scenario.

 

” target=”_blank”>[Current Item: Title]

 


Since this workflow runs whenever items are updated, the site owners will be able to quickly update the related search terms. And since the values are just a column in a list, site owners will be able to create a web part that displays only that field and display the web part anywhere on the site. In the example below clicking on the link called Procedure will open a new window with a search query on the term Procedure.


To update the list the site owner simply needs to add a new list item to the list (Note: if you didn’t want the extra field to be displayed on the list form you could hide it via InfoPath or by creating a custom content type):


Keep in mind that there is a lot you can do with search parameters in the URL so you could also limit this search to scope or to multiple parameters. I am sure there are multiple ways to accomplish this same task, but I found this solution a pretty quick and easy method that I can see as valuable in a few different scenarios. I hope you find it useful!

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