TransWikia.com

How to get number of views count for post in Discussion List in SharePoint

SharePoint Asked by Vamshi on November 17, 2021

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.

2 Answers

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.

Answered by Mike2500 on November 17, 2021

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.

Answered by Muskan on November 17, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP