SharePoint : Create Dynamic QueryText in Default Search Result WebPart

I’m going to explain you how to make a dynamic QueryText in a default Search Result WebPart in SharePoint

Edit your WebPart Query


You will arrive on the Query Builder page, first switch to advanced mode. You will see something like this :


So how to make the query below being dynamic ?

Simply by using the property {searchboxquery}, this let you the possibility to pass argument by the url parameter k

for example :

if you have the URL  :

and the query :

{searchboxquery}  (IsDocument:”True” OR contentclass:”STS_ListItem”)  DomainName={QueryString.Title}  ContentTypeId=0x010017D2CAFC0643EB42808970F6E7596DA80041E13F97EEA8D34586CF9DB6B57C4C76

What’s SharePoint is going to do ?

SharePoint will replace the value of k in the {searchboxquery}. So the query will become :

Service:SharePoint (IsDocument:”True” OR contentclass:”STS_ListItem”)  DomainName={QueryString.Title}  ContentTypeId=0x010017D2CAFC0643EB42808970F6E7596DA80041E13F97EEA8D34586CF9DB6B57C4C76

You can pass several arguments like this, by splitting the argument with a space. Please take care that k is a URL parameter so you should use this for special characters :

  • %3D is the equals sign (=)
  • %20 is the space sign (” “)
  • %3A is the colon sign (:) , this one is used in SharePoint query to means contains
This entry was posted in SharePoint. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s