1

I was reading this page where I found out the internal names for likes and comment counts in modern pages (communication sites) using a highlighted content with CAML query

https://www.eliostruyf.com/getting-likes-and-comments-from-modern-pages/

and used a CAML editor to find the code to get all pages that have at least one like or one comment.

The query produces all results of all pages.

What am I doing wrong? enter image description here

5
  • what source are you selecting in the HQWP? I've noticed this: "This site and This site collection uses KQL query strings. Document library and Pages library on this site uses CAML query strings. " Commented Aug 28, 2019 at 12:19
  • the page library since I was able to build the CAML query, I am unable to build the KQL query so I tried what was easier
    – susan
    Commented Aug 28, 2019 at 14:49
  • i wrote already several times that I am working with pages and comments and likes in pages, why you keep bringing up that it does not work for documents?
    – susan
    Commented Aug 28, 2019 at 15:29
  • My bad, Susan. Sorry, I haven't read your comment carefully. I am fairly busy and don't have much time to read thoroughly. Commented Aug 28, 2019 at 15:32
  • Have you tried to execute your CAML query in any tool/code that is not Highlighted content? Does it produce any results? Commented Aug 28, 2019 at 15:47

1 Answer 1

0

My observations:

  • _CommentCount and _LikeCount must first exist on the list item. To verify it, try adding these to the view. If you can't - then it's a problem
  • If your CAML query 1) refers to _CommentCount and _LikeCount and 2) returns 0 items - HQWP will actually return everything. I think, it's a bug.
  • Different sources use different Queries. Document Library, for example, uses CAML and "This site collection" source" uses KQL

enter image description here

enter image description here

There is nothing wrong with the Query you used. It works fine in lists where _LikeCount and _CommentCount exist:

enter image description here

enter image description here

6
  • there are some comments and some likes, I am not picky and i would be happy to have a roll up that shows pages that either have 1 like or more or 1 comment or more, so it will have to be related with OR. However, it is still not working
    – susan
    Commented Aug 28, 2019 at 15:04
  • if there are some comments and likes, can you add these columns to the List view? Commented Aug 28, 2019 at 15:27
  • they are there by default
    – susan
    Commented Aug 28, 2019 at 15:29
  • With my query builder I was not able to write a condition such as "greater than zero" therefore I selected 'is not null' but if the likes are ZERO maybe the system considers ZERO as 'not null' and maybe this is why I am not getting results. What is the right CAML for greater than zero? my query builder does not let me use that for this field
    – susan
    Commented Aug 28, 2019 at 15:37
  • Try a different Caml builder. I have constructed this one and it works fine: <Where> <Gt> <FieldRef Name="_LikeCount" /> <Value Type="Integer">0</Value> </Gt> </Where> I'm using CamlJS Console: chrome.google.com/webstore/detail/camljs-console/… Here is a quck demo: imgur.com/L0uvxdW Commented Aug 28, 2019 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.