1

I have a requirement where i need to retrieve and display view count for each post in discussion list and display it in a web part using JSOM. For example Post 1 has seen by 10 members then view count has to display as 10 for Post 1. Same thing for Post 2 in discussion list.

Can you guys please let me know, How we can get the view count for each separate post in discussion list.

Thanks in advance.

0

Create a column in list, and set 0 as a default value in the column. Now from where you are viewing the item. write a function to add the value by 1 in that column. Using this way you can count the no of view per item.

| improve this answer | |
  • Currently we are viewing the item from OOTB discussion list. When we open any post in discussion list, It is opening up that post in Flat.aspx page view which is OOTB view. How can we write custom function in OOTB view to update view count. This view will load based on post name and id. The post is opening up in below location"sitecollection/ListName/Flat.aspx?RootFolder=serverRelativeURLListName/PostName&FolderCTID=0x01200200DEEE149C55F8CF4F9894CC028A57AEAF".. Please suggest. – Vamshi Jul 19 '17 at 14:34
0

If you search for a discussion board post that's been in the system for a little while, and hover over the search result, you'll note that there is an OOB view counter that appears. This data is not live, and is updated via the usage analytics jobs, which I think are run once a day. If you think these restrictions are still workable, you can access the data via a rest call to the search service:

https://somehost.sharepoint.com/_api/search/query?querytext='path:"https://somehost.sharepoint.com/Lists/Discussion Board List/somepost"'&rowlimit=10

In the results of the REST call, look for the ViewsRecent and ViewsLifetime fields.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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