How to check if a Rating is enabled for a sharepoint online list using JavaScript?

137 views Asked by At

I am writing a JavaScript code where I want to allow user to provide star ratings to a particular article. This code will be in the form of widget. SO I want to first check if the Rating is enabled for a given sharepoint list. So, if the Rating is enabled then execute Rating related code.

I know we can do this by checking if Rating, AverageRating columns are present in a list. However I don't want to go that way because there might be a possibility where user has created those columns manually and Rating setting is disabled.

Can anyone provide a sample JS code for this?

1

There are 1 answers

0
Amos On

As far as I know, you can only determine whether the rating function is enabled by checking whether the related column is rated again.
Three columns will be automatically created after the Rating function is turned on. enter image description here
You can check that these three columns are all co-existing to avoid the impact of users creating columns with the same name. After the rating is turned on, the column with the same name will also be converted into a rating column.

Default internal name of rating column: enter image description here I create a separate column with the same name.
enter image description here

Then I turn on Rating.

enter image description here