SOLVED

HCWP - Custom query from selected site

%3CLINGO-SUB%20id%3D%22lingo-sub-2105376%22%20slang%3D%22en-US%22%3EHCWP%20-%20Custom%20query%20from%20selected%20site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2105376%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20all%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20use%20the%20HCWP%20to%20fetch%20some%20content%20from%20outside%20the%20site%20collection%20where%20I%20have%20placed%20the%20HCWP.%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20this%20purpose%20I%20am%20using%20a%20custom%20query%20in%20order%20to%20get%20content%20from%20a%20specific%20list%2C%20this%20does%20however%20not%20work%20and%20no%20content%20is%20shown.%3C%2FP%3E%3CP%3EThis%20will%20most%20like%20be%20caused%20by%20me%20having%20no%20idea%20how%20to%20properly%20make%20use%20of%20KQL.%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EI%20am%20using%20this%20query%3A%3CBR%20%2F%3E%3CBR%20%2F%3EPath%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2F%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2F****.sharepoint.com%2Fsites%2F*****%2F%3CLISTNAME%3E%26nbsp%3B%3C%2FLISTNAME%3E%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20found%20that%20in%20another%20thread%20that%20seems%20to%20be%20dead%2C%20so%20I%20decided%20open%20up%20a%20new%20discussion%20about%20it.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDoes%20anyone%20have%20any%20idea%20how%20to%20accomplish%20what%20I%20am%20trying%20to%20do%2C%20or%20if%20it%20is%20even%20possible%3F%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2105376%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2105412%22%20slang%3D%22en-US%22%3ERe%3A%20HCWP%20-%20Custom%20query%20from%20selected%20site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2105412%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F476096%22%20target%3D%22_blank%22%3E%40miclarsen1%3C%2FA%3E%26nbsp%3BHello%2C%3CBR%20%2F%3E%3CBR%20%2F%3EAre%20the%20sites%20connected%20through%20a%20Hub%20site%3F%20By%20connecting%20sites%2C%20you%20allow%20data%20to%20be%20fetched%20between%20site%20collections%20(AKA%20sites).%3CBR%20%2F%3E%3CBR%20%2F%3EYours%20sincerely%2C%3CBR%20%2F%3EAref%20Halmstrand%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2105511%22%20slang%3D%22en-US%22%3ERe%3A%20HCWP%20-%20Custom%20query%20from%20selected%20site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2105511%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F476096%22%20target%3D%22_blank%22%3E%40miclarsen1%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUsing%20path%20in%20custom%20query%20still%20works.%20You%20can%20either%20use%20%3CSTRONG%3EPath%3C%2FSTRONG%3E%20or%20%3CSTRONG%3EListID%3C%2FSTRONG%3E.%20Follow%20below%20steps%3A%3C%2FP%3E%3COL%3E%3CLI%3EEdit%20HCWP%20and%20Select%26nbsp%3B%3CSTRONG%3ECustom%20query%3C%2FSTRONG%3E.%3C%2FLI%3E%3CLI%3EIn%26nbsp%3B%3CSTRONG%3ESource%20%3C%2FSTRONG%3Edropdown%2C%20choose%26nbsp%3B%3CSTRONG%3ESelect%20sites%3C%2FSTRONG%3E.%3C%2FLI%3E%3CLI%3ESelect%20the%20site%20you%20want%20to%20target%20by%20searching%20or%20entering%20URL%3C%2FLI%3E%3CLI%3EIn%26nbsp%3B%3CSTRONG%3EQuery%20text%20(KQL)%3C%2FSTRONG%3E%26nbsp%3Badd%20query%20like%20given%20below%20and%20click%26nbsp%3B%3CSTRONG%3EApply%3C%2FSTRONG%3E.%3C%2FLI%3E%3C%2FOL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-javascript%22%3E%3CCODE%3EPath%3A%22https%3A%2F%2Ftenant.sharepoint.com%2Fsites%2FsiteName%2Flists%2FlistName%22%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOR%20you%20can%20use%20GUID%20of%20your%20list%20like%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-javascript%22%3E%3CCODE%3EListID%3Aaa28e6df-50b3-42a3-9b3f-6f25e2dcc220%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20can%20get%20the%20GUID%20of%20list%20from%20list%20settings.%3C%2FP%3E%3CP%3E%3CSTRONG%3EDocumentation%3C%2FSTRONG%3E%3A%26nbsp%3B%3CA%20title%3D%22Use%20the%20Highlighted%20content%20web%20part%22%20href%3D%22https%3A%2F%2Fsupport.microsoft.com%2Fen-us%2Foffice%2Fuse-the-highlighted-content-web-part-e34199b0-ff1a-47fb-8f4d-dbcaed329efd%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EUse%20the%20Highlighted%20content%20web%20part%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CHR%20%2F%3E%3CP%3EPlease%20click%20%3CSTRONG%3EMark%20as%20Best%20Response%3C%2FSTRONG%3E%20if%20my%20post%20helped%20you%20to%20solve%20your%20issue.%20This%20will%20help%20others%20to%20find%20the%20correct%20solution%20easily.%20It%20also%20closes%20the%20item.%20If%20the%20post%20was%20useful%20in%20other%20ways%2C%20please%20consider%20giving%20it%20%3CSTRONG%3ELike%3C%2FSTRONG%3E.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2106133%22%20slang%3D%22en-US%22%3ERe%3A%20HCWP%20-%20Custom%20query%20from%20selected%20site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2106133%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F373269%22%20target%3D%22_blank%22%3E%40ganeshsanap%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOk%20that%20seems%20to%20have%20done%20the%20trick.%26nbsp%3B%3C%2FP%3E%3CP%3EThere%20is%20however%20one%20more%20thing.%26nbsp%3B%3C%2FP%3E%3CP%3ENow%20that%20content%20is%20being%20fetched%20by%20the%20webpart%2C%20two%20items%20are%20shown%20in%20the%20webpart%2C%20but%20there%20is%20only%20one%20item%20in%20the%20list.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22miclarsen1_0-1611841398350.png%22%20style%3D%22width%3A%20700px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F250254i8C23AA770B89C5A3%2Fimage-dimensions%2F700x214%3Fv%3D1.0%22%20width%3D%22700%22%20height%3D%22214%22%20role%3D%22button%22%20title%3D%22miclarsen1_0-1611841398350.png%22%20alt%3D%22miclarsen1_0-1611841398350.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EAs%20you%20can%20see%20here%2C%20there%20are%20two%20items%20being%20shown.%20The%20one%20with%20the%20red%20crossovers%20is%20the%20actual%20item%20in%20the%20list%2C%20but%20the%20other%20one%20%22IT-IT%20Status%22%2C%20is%20actually%20just%20a%20link%20to%20the%20list%20itself%20and%20I%20really%20dont%20understand%20why%20it%20is%20present%20here.%3C%2FP%3E%3CP%3EMy%20guess%20is%20that%20it%20has%20something%20to%20do%20with%20content%20types%2C%20but%20I%20can't%20say%20for%20certain.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
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 (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!