What block allows to count the amount of items in a list?

Hello once again!

I am trying to count the amount of items in a Table scheme.
Example:
image

Get amount of “anmalningar” in the Table “Aktiviteter”

How is it achievable?

Use the following block to get a number of objects in a table (or a number of objects matching a query):

How should I query it?

On page enter it collects all events and places them into a dynamic list.
Inside of that dynamic list there are multiple activities (Aktiviteter) with multiple registrations (anmalningar).

I need to get from every single activity the amount of registrations made.
This gives me an error.

I know I am doing it completely wrong because it does not makes sense… but I cant find a way around it…

What does the relationship in the database look like between activities and registrations?

image

It’s a simple 1 to many relationship.

This is a relationship between activities and users. You can see it say right there RELATION TO: Users.

I am asking about the relationship between activities and registrations.

That is the registration, there are no forms, when the user creates an account, the current user account will be linked to the event.
The current user can register / remove registration simply by clicking a button in the dashboard.

So you want to know the count of users for each actiivity?

Yes

This is how you can get the user count for each activity:

I used this block

It gives me this error:

Another follow up question:
What is the difference between relations and properties in this block?

To my understanding relations loads a list with objects from an API, the properties does exactly the same thing???

And by the way, if I do this:

I get this

Here’s a visual description:

Relations load related objects (entirely).
Properties load specific property values.

And regarding the second error:

Regards,
Mark

Hi again Mark,
I really apologize, you guys must be fed up with me and my questions… But it doesn’t work.

I notice that it loads the count of “anmalningar” but everything else is not loading.

Can it be something else?

Best regards,
Rafael

Hi Rafael,

What is the name of the page where you have that logic?

Regards,
Mark

Hi Mark!
The page is “dashboard_ungdom”.

Best regards
Rafael

What is the flow to get to that page in your app? The page expects currentUser to be in AppData, that object will not appear out of nowhere. There is got to be some logic elsewhere that puts the user into AppData. Please provide clear instructions.

Regards,
Mark

In the index page there is a “Logga In” button on the header that takes the user to the “login” page.

When the user logs in, it sets the variable “loggedInUser” into:

  1. AppData as property “currentUser”
  2. Local Storage Data as key “currentUser” (this because when the page is refreshing it automatic logs the user out and I read in a support ticket that the data should be stored locally).
  3. After it navigates to page “dashboard_ungdom”

On that page enter

  1. Sets the dymanic list items to Container_aktiviteter_list from an API (where the problem is)
  2. Gets the currentUser from AppData to a variable “user” so I can print it to check in the console the current user data is still available.
  3. I also print the dynamic list so I can see what data the API gives me and what error it gives me.

I created a page called dashboard_mark. I fixed the query there and the data is now loaded. The rendering of the UI is messed up, this is something you need to fix.

Regards,
Mark

Thank you! I found the rendering issue, it is a reusable element that is not loading properly for some reason.

Thanks a lot for the help!