Thursday, December 19, 2013

Use the 'a=' url parameter when passing 'hidden' search strings to a SharePoint search page

On several sites we have links that trigger searches by passing the term GUID to the search page through the 'k=' parameter, as you can see from the URL. This is a neat way of showing all items tagged by a certain term. In fact you can use this method to pass any search string to a search page, not just metadata guids (example: ...resultpage.aspx?k=author:someone).







So this actually works great, but for one thing. I would like to not display the rather cryptic search string in the search box. In addition to the core search results web part on a search page the search box web part also picks up the value passed into the page by the 'k=' parameter, and displays it as the current searched for string.










One solution is to deselect the 'Display submitted search' option in the search box web part properties configuration, but I choose not to because I would like normal search strings entered in the box by the users to display.

After doing a lot of searching for alternatives one of my local MVPs, Mikael Svenson, came up with the easy solution: use the 'a=' parameter instead of 'k='. Has exactly the same effect on filtering the core search results web part, but without displaying the search string in the search box.

One important thing to note is that the core search results web part needs an additional value. Just passing in a value for the 'a=' parameter will return nothing. In my case I added a simple additional query in the 'Append text to query' field in the core results edit web part properties. I used 'IsDocument=1' because I want the search page to list all documents within the defined search scope to be listed if no other search string is given by the user.


Friday, December 6, 2013

How to set hyperlink url and display name in Sharepoint Designer workflow

A Hyperlink field is made up of two separate parts, the clickable display name and the actual URL. In SharePoint Designer Workflow there is only one field to set for both values.

I was creating a custom 'My favorites'  list when this problem came up. I wanted to create a simple workflow in a document library where users could opt to create links to certain documents in the favorites list by running the workflow for each of these items.

The central part of the document library workflow is of course the create item action. The action is simply set to create an item in the favorites list that sets the item's URL field. I created a workflow variable where I define the string that will hold both the link's display name and URL. Thus the first action of the workflow is to update the variable.

In the string builder dialog simply put together: [%Current Item:URL%], [%Current Item:Name%]. The URL and display name is thus separated by a comma and space. Both of these are important.