I have a list that has items that are related to another table and user actions should update the other table and refresh information displayed in the list.
For simplicity, let’s say these are chairs and I want to show when a chair has been occupied by a user. Kind of a very simple reservation that behaves like a light switch - on/off.
I have a collection of “Chairs” with photos and it has a relationship with another collection called “Occupied Chairs.”
When the user clicks a photo of a chair, an action creates a new record in “Occupied Chairs” and is populated with the username and status which is set to TRUE.
When a user clicks a chair I want their username to be displayed over the photo of the chair.
When they click their name (once displayed), I want to update the occupied chair record status to FALSE, and remove the display of the user over the photo.
In essence, this vacates the chair and makes it available for someone else to select.
Approach: the occupied or not behavior is accomplished by a text field that is SOMETIMES VISIBLE only if the related “Occupied Chair” record is set to TRUE and hidden when FALSE. Thus the username is only shown when the chair is occupied.
My issue is that when the occupied chair record is created, the functionality of the SOMETIME VISIBLE rule does not work. The Occupied Chair record is created, but the behavior of showing the username from that record does not occur.
The advanced options for this list is set to Auto Refresh when users add new items.
Again, in summary I have a list that has items that are related to another table and user actions should update the other table and refresh information displayed in the list. Ideas?
Thinking about how I could word this better:
It appears the scope of the “SOMETIMES VISIBLE” rule only includes data in the collection specified for the list and does not extend to any related records in other collections.
This is odd, since the purpose of relational databases would be streamlined data elements and records. I shouldn’t have to update the parent chair record.
I will experiment with different relationship types to see if that may have any bearing 1:n , n:1 and n:n
Wow. I stripped it down and just set the list to show fields that were in the related collection. They do not show even in a simple situation.
My Chair record has a specific related “occupied chair record” with a specified username. Does not show in my simple custom list. Bizarre.
Solved. Needed to create a list within a list to expose the data from the related database. Regular list for the chairs, single item .list for the Occupied chairs data. I’ve moved to rookie level 2.
Great that you’ve solved this problem by yourself, congrats!
Just my 2 cents: I am not sure what is your real-life usecase, but for chairs and users I would question the necessity of having an extra collection. Chair is an entity which can be either occupied or free. Unless you need to store the “occupation history”, you can simply add T/F property “occupied” and create a relationship with user upon chair booking.
Things will change, however, if you have something like a Hall with Chairs, and you need to manage chair bookings for different Shows. Then of course “occupied” T/F + relationship won’t work: chair is the same but shows are different. In this case you’ll need an extra collection, call it “ShowBookings” (which will have relationship with Users, Chairs, Shows and some extra info like booking date).
And to display the chairs for a certain show you’ll need to create a list of ShowBookings with the appropriate filter for a Show; you can get Chair and User info for each ShowBooking using the relationship.
Displaying the list of all chairs for the show (occupied/free) will be a bit challenging though. It’s possible to put list of bookings inside list of chairs, but this is a unscalable solution for large number of chairs (imagine you have 100 chairs - then you’ll have to load single-item list of bookings for each chair, 100 times in total).
So I’d rather suggest using conditional visibility icon here (for each chair, if Chair → Bookings → Count, where Show = current show, is greater than 0) - this icon should be displayed when the chair is occupied for a current show. The condition counts the number of bookings for current chair and for current show, and if it is >0 then the icon is displayed.
But I believe this is a bit different story. Decided to write this post as I think this could be useful in future.
Thank you Victor, very helpful to consider other approaches. There will be history for chair “bookings” but in this case only about 20 chairs. I’m going to explore the conditional visibility you suggested. Many thanks! Matt