SOLVED

HCWP - Custom query from selected site

Brass Contributor

Hi all,

 

I am trying to use the HCWP to fetch some content from outside the site collection where I have placed the HCWP. 

For this purpose I am using a custom query in order to get content from a specific list, this does however not work and no content is shown.

This will most like be caused by me having no idea how to properly make use of KQL. 

I am using this query:

Path: https://****.sharepoint.com/sites/*****/<listname> 

 

I found that in another thread that seems to be dead, so I decided open up a new discussion about it.

 

Does anyone have any idea how to accomplish what I am trying to do, or if it is even possible? 

5 Replies

@miclarsen1 Hello,

Are the sites connected through a Hub site? By connecting sites, you allow data to be fetched between site collections (AKA sites).

Yours sincerely,
Aref Halmstrand

@miclarsen1 

 

Using path in custom query still works. You can either use Path or ListID. Follow below steps:

  1. Edit HCWP and Select Custom query.
  2. In Source dropdown, choose Select sites.
  3. Select the site you want to target by searching or entering URL
  4. In Query text (KQL) add query like given below and click Apply.

 

Path:"https://tenant.sharepoint.com/sites/siteName/lists/listName"

 

OR you can use GUID of your list like:

 

ListID:aa28e6df-50b3-42a3-9b3f-6f25e2dcc220

 

You can get the GUID of list from list settings.

DocumentationUse the Highlighted content web part 


Please click Mark as Best Response if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

 

Hi @ganeshsanap ,

 

Ok that seems to have done the trick. 

There is however one more thing. 

Now that content is being fetched by the webpart, two items are shown in the webpart, but there is only one item in the list. 

 

miclarsen1_0-1611841398350.png

As you can see here, there are two items being shown. The one with the red crossovers is the actual item in the list, but the other one "IT-IT Status", is actually just a link to the list itself and I really dont understand why it is present here.

My guess is that it has something to do with content types, but I can't say for certain. 

best response confirmed by miclarsen1 (Brass Contributor)
Solution

@miclarsen1 

 

Yes, that is the link to list itself. You can filter it out using below query so that HCWP will only show the list items:

 

Path:"https://tenant.sharepoint.com/sites/siteName/lists/listName" contentclass:STS_ListItem

 


Please click Mark as Best Response if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

@ganeshsanap 

 

Brilliant - thanks a lot!

1 best response

Accepted Solutions
best response confirmed by miclarsen1 (Brass Contributor)
Solution

@miclarsen1 

 

Yes, that is the link to list itself. You can filter it out using below query so that HCWP will only show the list items:

 

Path:"https://tenant.sharepoint.com/sites/siteName/lists/listName" contentclass:STS_ListItem

 


Please click Mark as Best Response if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

View solution in original post