SharePoint Online - CAMLQuery between site collections RRS feed

  • Question

  • Hi All,

    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.

    Custom Columns:

    BusinessFunctions (Managed Metadata)

    - Sales

    - Marketing

    - Technical

    BusinessRoles (Managed Metadata)

    - Director

    - Dept. Manager

    - Sales Rep

    - Technicians

    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.

    REF: https://support.microsoft.com/en-us/office/use-the-highlighted-content-web-part-e34199b0-ff1a-47fb-8f4d-dbcaed329efd?ui=en-us&rs=en-us&ad=us

    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?



                      <FieldRef Name='BusinessFunction' />
                      <Value Type='TaxonomyFieldType'>Marketing</Value>
                      <FieldRef Name='BusinessRole' />
                      <Value Type='TaxonomyFieldType'>Dept Manager</Value>
                   <FieldRef Name='BusinessRole' />
                   <Value Type='TaxonomyFieldType'>Technician</Value>
                <FieldRef Name='BusinessRole' />
                <Value Type='TaxonomyFieldType'>Sales Rep</Value>



    I hope someone can help me to resolve this issue. Thanks! :)

    Tuesday, September 8, 2020 9:59 AM