How to filter Content Search Webpart results on Managed Metadata term dynamically through URL Parameter
-
13-02-2021 - |
Question
I have a landing page with a content search webpart that I want to be dynamically filtered by an URL like this one http://mysharepoint.com/site1/home.aspx?tagterm=#0a1658abf-cc9d-495c-a8cc-e25953aad57e. It should be grabbing the term GUID from the term store and filtering upon it in the query below but it returns nothing after I save close the query dialog box. While editing the query the and testing in the TEST tab it works perfectly. Am I missing some sort of special encoding from the URL? I added some visual examples below.
The query:
owstaxidmetadataalltagsinfo:{QueryString.tagterm} (contentclass:STS_ListItem OR IsDocument:True) (ContentTypeId:0x010100B49CA5009A6365469E63CD3AC5F1FDA8* OR ContentTypeId:0x01010A00ED2A591570802345BA22687CF8A919F1*)
Why would results return in test but not from the URL?
Solution
I found out the issue is that because of the special characters in the URL you have to put them inside double-quotes for them to work.
The url now looks like http://mysharepoint.com/site1/home.aspx?tagterm="#0a1658abf-cc9d-495c-a8cc-e25953aad57e"