HCWP CAML Query - How to order by popularity/views/likes?

%3CLINGO-SUB%20id%3D%22lingo-sub-2280547%22%20slang%3D%22en-US%22%3EHCWP%20CAML%20Query%20-%20How%20to%20order%20by%20popularity%2Fviews%2Flikes%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2280547%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20a%20SharePoint%20site%20with%20numerous%20Site%20Pages%20that%20contain%20guides%20for%20using%20our%20IT%20systems.%20On%20the%20Home%20Page%2C%20I'm%20trying%20to%20automatically%20organize%20them%20using%20Highlighted%20Content%20Web%20Parts.%20The%20site%20page%20library%20has%20a%20multi-choice%20column%20I%20use%20to%20filter%20the%20HCWP.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20issue%20I%20have%20is%20I%20want%20the%20HCWP%20to%20only%20show%20the%20most%20popular%20pages%20in%20each%20filtered%20category.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20filter%20I%20have%20works%20fine%2C%20but%20I%20can't%20figure%20out%20what%20property%20to%20use%20for%20the%20OrderBy.%20None%20of%20them%20seem%20to%20do%20anything.%20If%20I%20use%20the%20%22Title%22%20property%20it%20works%20as%20expected%2C%20so%20the%20code%20should%20be%20fine%2C%20the%20problem%20is%20what%20property%20to%20use%20for%20ordering%20by%20popularity%3F%20I'm%20not%20picky%20on%20how%20to%20define%20popularity%2C%20whether%20it's%20number%20of%20likes%20or%20views%20or%20something%20else.%20I've%20tried%20LikesCount%2C%20ows_LikesCount%2C%20ViewsLast1Days%2C%20ViewsRecent%2C%20and%20ViewsLifeTime.%20These%20are%20all%20managed%20or%20crawled%20properties.%20I%20don't%20know%20if%20they're%20actually%20being%20used%20by%20the%20site%20pages.%20The%20%22Like%20count%22%20column%20in%20the%20Site%20Pages%20library%20does%20update%20correctly%2C%20but%20I%20have%20no%20idea%20if%20that's%20related%20to%20the%20LikesCount%20managed%20property.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markdown%22%3E%3CCODE%3E%3CVIEW%3E%0A%3CQUERY%3E%0A%3CORDERBY%3E%0A%3CFIELDREF%20name%3D%22LikesCount%22%20ascending%3D%22FALSE%22%3E%3C%2FFIELDREF%3E%0A%3C%2FORDERBY%3E%0A%0A%3CWHERE%3E%0A%3COR%3E%0A%3CCONTAINS%3E%0A%3CFIELDREF%20name%3D%22ITKnowledgebase%22%3E%3C%2FFIELDREF%3E%0A%3CVALUE%20type%3D%22Choice%22%3ESharePoint%3C%2FVALUE%3E%0A%3C%2FCONTAINS%3E%0A%3CCONTAINS%3E%0A%3CFIELDREF%20name%3D%22ITKnowledgebase%22%3E%3C%2FFIELDREF%3E%0A%3CVALUE%20type%3D%22Choice%22%3EOneDrive%3C%2FVALUE%3E%0A%3C%2FCONTAINS%3E%0A%3C%2FOR%3E%0A%3C%2FWHERE%3E%0A%3C%2FQUERY%3E%0A%3C%2FVIEW%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2280547%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
New Contributor

I have a SharePoint site with numerous Site Pages that contain guides for using our IT systems. On the Home Page, I'm trying to automatically organize them using Highlighted Content Web Parts. The site page library has a multi-choice column I use to filter the HCWP.

 

The issue I have is I want the HCWP to only show the most popular pages in each filtered category.

 

The filter I have works fine, but I can't figure out what property to use for the OrderBy. None of them seem to do anything. If I use the "Title" property it works as expected, so the code should be fine, the problem is what property to use for ordering by popularity? I'm not picky on how to define popularity, whether it's number of likes or views or something else. I've tried LikesCount, ows_LikesCount, ViewsLast1Days, ViewsRecent, and ViewsLifeTime. These are all managed or crawled properties. I don't know if they're actually being used by the site pages. The "Like count" column in the Site Pages library does update correctly, but I have no idea if that's related to the LikesCount managed property.

 

 

<View>
<Query>
<OrderBy>
<FieldRef Name="LikesCount" Ascending="FALSE" />
</OrderBy>

<Where>
<Or>
<Contains>
<FieldRef Name="ITKnowledgebase" />
<Value Type="Choice">SharePoint</Value>
</Contains>
<Contains>
<FieldRef Name="ITKnowledgebase" />
<Value Type="Choice">OneDrive</Value>
</Contains>
</Or>
</Where>
</Query>
</View>

 

 

0 Replies