I am having problems with a Highlighted Content WebPart in SharePoint Online where I am using a custom CAML query to filter content from a Page Library on another site collection.
I have created a site collection where I have a Page Library with 2 custom columns to filter the Pages in the Page Library.
On another site collection I have added a Highlighted Content WebPart where I need to query the 2 custom managed metadata columns to filter the pages that should be shown.
BusinessFunctions (Managed Metadata)
BusinessRoles (Managed Metadata)
Example Pages Library Content:
Title Business Function Business Role
Home.aspx Marketing Director
Page1.aspx Sales Director
Page2.aspx Sales Sales Rep
Page3.aspx Technical Dept Manager
These 2 columns have been added to the Pages Content Type. I have also checked that they exist as a managed property in the Search Schema and they are both listed as managed properties "owstaxidBusinessFunctions" and "owstaxidBusinessRoles".
If I use the Out of the Box filters I cannot create a filter with an AND statement as adding 2 of the same column results in an OR query statement as shown below.
This means I need to create a CAML query to resolve the challenge but I cannot get the Query to work across site collections?
Here is an example of the type of query I want to create so I only return Pages with the BusinessFunction Marketing and BusinessRole Director.
I have also tried to create a very simple query with a single property but this doesn't work either across site collections?
<View> <Query> <Where> <And> <And> <And> <Contains> <FieldRef Name='BusinessFunction' /> <Value Type='TaxonomyFieldType'>Marketing</Value> </Contains> <NotIncludes> <FieldRef Name='BusinessRole' /> <Value Type='TaxonomyFieldType'>Dept Manager</Value> </NotIncludes> </And> <NotIncludes> <FieldRef Name='BusinessRole' /> <Value Type='TaxonomyFieldType'>Technician</Value> </NotIncludes> </And> <NotIncludes> <FieldRef Name='BusinessRole' /> <Value Type='TaxonomyFieldType'>Sales Rep</Value> </NotIncludes> </And> </Where> </Query> </View>
I hope someone can help me to resolve this issue. Thanks! :)