Need help sorting Objects from firebase rest api!

I am trying to build a fitness app to track my participations health and wellness. I have class participants enter their scores in my app. It is then saved to my firebase backend via REST API by binding the submit button to the container, the request body is linked to my datavars.scoreboard.field.scores.integerValue. The data variable is an object.

I retrieve the List of Scores from REST API, I wish to repeat them in a list, sorted according to who has the highest scores. However, the data variable is an object. If I use a list, the content section of the container says unable to assign number to list of objects. If I use an object, I cannot use the sort_by_key function or the order function. And also, the data has to be saved as an object because it needs to be linked to Firebase backend in Json format, which reads in Key and Value.

Please send help!
Anyone? @Mevi @JOHN_WORSHAM @Erin_Wagner @Harri_Sarsa @Mari @Cecilia @Akseli_Virtanen

What does [0] mean? Why is it automatically added into the data path? I didnt add it in. How do I rectify it?

Here are some images of my project as reference for you to help troubleshoot!


This is my schema


This is the form my participants fill in.


This is still the form page. This is my request body in the HTTP req sent to my firebase backend via hyperlink.


This is the scoreboard page, I want the scores sorted out such that my participants to be able to see who attained the highest score.


This is still the scoreboard page. The formula says I cant assign object to list. But if I change my schema from object to list of object, the content page will show number is not assignable to list of objects with 1 property


This is the binding content of the container. Same scoreboard page.

Hi!

From the screenshots it looks like the datavar is List type, not Object. Use [0] only when you want to access the first item in the list. The reason the formula editor has suggested this is because you’re trying to access an Object value inside an Object in the list. The correct formula would probably be something like ORDER(data.Scoreboard1, item.Name.stringValue) or similar.

Hi Mevi,

If I change the object to a list, when I bind it to a repeating paragragh, it says number is not assignable to list.

Also do you have filters according to users email? I want different groups of people to access different content like member content, manager content and administrator content.

Cheers!
Wayne

Hi,

Please show me in which binding it’s complaining about number not assaignable to list, and what you’re trying to bind there. If you’re using ORDER, the first parameter has to be a list and the second the value by which you want to order the list in the first parameter by.

Access control is a tricky issue. For true security, they should be managed by your backend to avoid security leaks (see primer on security here). When your data is managed securely (so that an user who is not authenticated as an admin would not be able to get data they should not be able to get to, even if they would navigate to the page or break your app) you can hide/show certain elements in the UI so that users don’t get to see pages with no data or admin pages that they can do nothing in etc. I prefer to do this by having the information of the user’s groups in the currentUser or similar app variable in the app, and showing/hiding elements based on if they belong in the right groups. I definitely don’t recommend only filtering data in the app (and not starting from the backend) based on the email of the user, as this can be circumvented by a malicious user.