My problem/question relates to trying to display Responses to Questions in a RG, however, I want to limit the Responses to only the ‘latest’ by created date for a particular user or drop duplicate entries for a user.
Basically I’m looking to better understand list manipulation in Bubble because these challenges keep coming up.
- List Questions (Question)
- question_text (text)
- List Responses (Response)
- response_text (Text)
- Created by (user)
- user_email (text)
- for_group (Group)
- for_question (Question)
For a Group - I display the list of Questions in a RG.
- For each Question:
I want to display which User is responding (email)
Their response (text)
How would you limit the search/filter result to only the ‘most
recent’ response for a particular user (say by created date?) when a user
submits multiple responses?
Image below shows problem state:
In the example above you can see for a given Question, the same user submits multiple responses. I’d like to only display the latest response.
I’d like to learn how to handle Bubble data access, sorting, filtering to manage this situation! I’m keen on learning how to handle this challenge because I’ll need this information to build reports or summaries by date range later.
Thanks so much for your help,
Hi there, @sduxbury… if I understand your post correctly, you want something like the following where Jerry has responded twice (shown on the left) but only his latest response appears in the list (shown on the right). Is that the idea?
If that’s what you are shooting for, you could go about it a number of ways. One of those ways appears to be the path you are going down by having a list of responses associated with a question. If you go that route, you have to do some work to make sure a specific user only has one response in the list. So, when a user submits a response, you would have to check the list for another response associated with that user and remove that response as part of the action that adds the user’s latest response to the list.
Another way to go (and the way I went to create the screenshot above) is to group responses by user in the repeating group. Are you familiar with the
:group by option?
I should say I am by no means an expert in this particular area, but I have spent my share of time getting data to appear the way I want it to appear in repeating groups, so I thought I could provide some food for thought that might be helpful. Someone else may come along and give you the “exact right way” to set things up in order to get the desired result, but if there is one thing I have learned about Bubble, it’s that there are always multiple ways to solve a problem, and every way has its pros and cons.
Anyway, if you dig into the
:group by option and need any help, I would be happy to provide more information.
Thanks for making time to share your insight - I’ll check out the :group by and see if I can make progress there.
Update: Had a look at the :group by approach.
The problem I’m seeing (might be doing it wrong) is that when I use :group by Creator (User) I’m limited to accessing only fields from the User. In my Data Structure, User does have a list of responses of type Response, but that re-creates the initial problem of having multiple responses for the same Question by the same User.
Here I have nested RGs to 1) find all Questions for a particular Group. For each cell (Question) I want to display all the Responses (but limited to the most recent Response, per User).
I thought storing Responses as a list for each Question would make retrieving these and displaying easier, maybe there is a more Bubble appropriate way?
Search for Responses:grouped by Creator
Next I’m trying to display the user_email and response_text which are fields in Response. These would be in a RG for each Question. So ideally, we’d see Responses from each User for each Question.
The problem I have (below) is when using :group by Creator, I get limited to the fields in Creator (User) - which are not related to the Response. In the image below I tried to save Responses to User using a list_responses - but this re-creates the initial problem (having multiple responses for the same user for the same question). Seems circular.
Saw your direct message on this subject… I’ll respond there.
I could not quite figure out how to perform the list manipulation to remove Responses from a list of Responses where the same user had created multiple Responses.
Convinced this must be a common problem and there has to be a fairly clean way to resolve it.
In discussion with mikeloc - I changed the workflows to check for existing entries by a user and ‘make changes to’ the previous entry with the new data. Now I can simply display all the responses using nested RGs.