Explain Rating Control in PowerApps

Introduction

Rating is one of the most common features in social sites and for any of the interactive requirements by users. While I was developing ratings, I realized, there are lots of validation required in order to capture correct ratings.

Scenario

We will add a rating control and set display mode and default property as per the requirement.

Objective

The objective of this requirement is very demanding, as a rating of the concept is important in many of the scenarios. It is useful in concepts like idea ratings or article ratings. To calculate and project, we will create a SharePoint list as per the requirements.

Step 1. The list structure would look like below.

The list structure could be designed as per our needs.

Here for a demo, I have created 3 different lists and shown the data with its list structure.

  1. Article list structure
    Article list structure
  2. Article list content
    Article list content
  3. PostViewsOnArticle list structure
    PostViews
  4. PostViewsOnArticle Content
    PostViewsOnArticle Content

The third list will save data from Powerapps and the list structure looks like below.

 Powerapps

Step 2. Design screen and form as per requirement.

The below screenshot shows all the articles that are entered, on clicking on articles, we can see the details of the article and all the views that we got on that article. To show all articles, I have taken gallery control.

Design screen

Below is the display form, which shows the variable View value. Variable View value shows gallery-selected item details.

View value

Below form I would like to show all the views that people might have. When we click on each of the views, we can see the details, and after seeing the details, we can rate it. To show all the views we will again use Gallery control.

As we can see, I have deleted the title from the box label and provided a button so that I can show the title as text, and it remains clickable too.

Gallery control

Onselect of the button it should go to View description so the code looks like below.

View description

Step 3. Save the Logged User in a Global variable.

We keep logged-in user details in a global variable for performance improvement. Otherwise User(). The email could directly be used wherever required.

Global variable

Step 4. Add Rating list DataSource from SharePoint.

Add Rating List from SharePoint as DataSource

So that patch function can use this data source to store the ratings.

Add data

Rating

Step 5. DisplayMode property of Rating Control.

DisplayMode property of rating control at Article description page and views gallery.

DisplayMode

Step 6. Default property of Rating Control.

Default property of Rating control

Default property

Step 7. OnSelect property of Rating Control.

Below the OnSelect property, the function is optional in case it is needed. In my case, it is not required as the rating control is in view mode.

OnSelect property

Step 8. Create a new screen and a new form to show view details.

It is a representation of another method of rating control. What we saw in the above screen, little more in detail we will see in this screen. We will see validations on rating control in this scenario.

View details

Step 9. Add Rating Control to record ratings. Default Property of Rating Control.

As shown steps above to add rating control and set the default value to 0 are followed. Unlike above here, the display mode will depend upon the validations.

Same above feature we will be on a form where the user can view all the details of the item and then choose to rate, so we will include a rating control below the form which will show average ratings and total ratings and patch the ratings, your own ratings given will be shown.

Add Rating Control

Step 10. Here, the Display mode will not be viewed directly. It will work depending on the validations.

Below is another example with validation to set Display mode.

Set Display mode

Step 11. OnSelect of Rating Control.

Since I have handled the displaymode, It is not required to do validation on OnSelect so I am patching directly to the list.

Validation

Conclusion

In the above example, we saw how to use rating control, and how the data be saved in the SharePoint list. It is a useful scenario in the case of people people-oriented apps. Socially interactive app uses this feature popularly.


Similar Articles