Dec 02 2020 01:22 AM - edited Dec 02 2020 07:03 AM
Hello,
I am using the web part at https://web.archive.org/web/20201014031829/https://microsoft-search.github.io/pnp-modern-search/sear... in a Communication Site and I am trying to set a dynamic query that depends on a page property.
If set the query with a fixed value as: path:https://<tenant>.sharepoint.com/sites/contosonews/Photos Company=Microsoft, the results are correctly returned.
But if I change my query to use a page property called Company, it doesn't work. I am using a query variable explained in the above article as follows:
path:https://<tenant>.sharepoint.com/sites/contosonews/Photos Company={Page.Company}, the results are correctly returned.
IMPORTANT: Company is a choice field and the user chooses in the Page Details the value of the Company field when editing the page.
Tried to use a managed property also but I have to get the dynamic value from the page data itself which I don't think it can be done through managed property. it must be a valid query variable as in https://docs.microsoft.com/.../technical.../query-variables. This page refers Page.FieldName as the solution but couldn't get it to work yet.
How can I use the page property of type Choice (in this case called Company) in my search query to have a dynamic query?
Thanks
Dec 02 2020 02:24 AM
@Miguel Lopes Isidoro also hello
Dec 02 2020 05:55 AM
@Eva Vogel Hello :), Do you know the solution for this question?
Dec 02 2020 06:41 AM
@Miguel Lopes Isidoro try this: advanced Metadata KQL query language is a tricky one, also with user-defined query criteria on the modern SP layout with the "Highlighted Content Webpart": SharePoint Power Hour: Advanced Managed Metadata & Search - YouTube
All the best from Eva
Dec 03 2020 01:02 AM
Solution@Eva Vogel Solved. Token Page.FieldName must be placed in query template field in the web part, not in the query text Field. Thanks
Jul 10 2021 03:58 AM
we have the same problem. Could You please explain the solution better? With the example…
Jul 27 2021 02:39 AM
@Roco_Alvarez_Moret check the attached image.