My objective is to display whether a user has rated an item in a list or not. I need to retrieve the User ratings columns from SharePoint Online - see screenshot:
I'm going to retrieve it using REST through an SPFX webpart.
const columnsToRetrieve =
`Id, Author/Id, Editor/Id, Editor/Title, Status, Title, Created, LikesCount, LikedBy/Title, LikedBy/Id, LikedBy/EMail, AverageRating`
do {
if (!pagedItems) {
pagedItems = await Web(siteUrl).using(SPFx(context)).lists
.getByTitle(listName)
.items
.select(columnsToRetrieve)
.expand("Author, Editor, LikedBy")
.getPaged()
I've tried using Rating, rating, Rates
and several more but none are recognised.
I don't know what the real name is. There is next to no documentation referring to these columns.
Does anyone have any experience working with this column and perhaps could enlighten me?
~I've read: https://learn.microsoft.com/en-us/previous-versions/office/developer/sharepoint-2010/ff407954(v=office.14)#retrieving-social-ratings but it's no help and it refers to SP2010
You have to use the internal name of columns in SharePoint REST APIs.
You can get the exact internal name of your column by following this article: How to find the Internal name of columns in SharePoint Online? - you may need to use "Classic experience" method for some of the columns.
Here is the list of columns related to rating settings I have captured using above methods:
Display Name | Internal Name |
---|---|
User ratings | Ratings |
Liked By | LikedBy |
Number of Likes | LikesCount |
Number of Ratings | RatingCount |
Rating (0-5) | AverageRating |
Hope it helps!