Forum Academy Marketplace Showcase Pricing Features

Data mapping / using 'list of' fields

Hi, I have a query relating to the data structure:

Currently I have 2 ‘Things’ that I want to relate to each other so that I can run certain queries later.

a) ‘Chain’ which is a company that owns a number of ‘Shops’. It has a field called ‘Shops List’ which is a list of ‘Shops’ (e.g., ‘Chain’ = ‘Starbucks’ and ‘Shop’ = ‘a particular Starbucks cafe’)

b) ‘Shop’ which is a shop, store or cafe that sells various food and drink items. It has a field called ‘Member of Chain’ which is defined as type ‘Chain’

Ideally, I would like the ‘Shops List’ in a) to automatically populate as and when more ‘Shops’ are added to the database with the relevant ‘Chain’. However I don’t think this is possible at the moment (please tell me if it is), so instead I wanted to include a step in the workflow that ‘Adds’ the current ‘Shop’ to the ‘list of Shops’ under the relevant ‘Chain’. However when I try to do this (basing it on the example video although I appreciate that the example uses the list function under the ‘User’ thing which is a special type of ‘Thing’) I am unable to get it to ‘Add’ to the list. (Please see the screenshot). Perhaps because the ‘Chain’ is not the primary ‘Thing’ being updated in this workflow, it does not want to allow to ‘Add’ to a list in a secondary ‘Thing’.

Anyway, any help / tips appreciated.

Many thanks

Simon

Hi,

“Make changes to list of …” is a little confusing at first I think. It is about providing a list of things “to change” (so the result of a search, all things that match certain criteria etc) and then applying a change to THAT LIST of things. So you could change the name of all Coffee Shops that have a certain Chain from Starbucks to Starbusts.

It isn’t about making changes to lists of things on the database. That comes in the next step, when you choose the value on the thing you want to change.

When you select something that is a list, it gives you a different set of actions, like add/remove.

So if you switch back to “Make Change to Thing”. In “To Change” you want to reference the chain you want to add the shop to. And then in Set Value select the list and add the shop thing to the list.

I hope that helps rather than confuses.

It might be easier to just have the chain type on the shop ? The searches (particularly the advanced ones) are pretty powerful and you should be able to do your queries by using a contains ?

As an example…

I am filtering a list based on the current_user being in a list (of Users) in User that created this Location. This combines multiple tables linked by lists, and it was a lot easier to do this that trying to think about how I might have written some SQL :smile:

2 Likes

After a quick test I have got this to work - that is very helpful, thank you.

I haven’t got as far as trying to set up the queries yet so you may well be right on that - I haven’t adjusted my thinking to Bubble yet and couldn’t resist this attempt at a 2-way ‘mapping’ although I am not sure it is of any use.

Now I can populate some test data I will be starting on the queries so no doubt will be back with ore questions in this forum!

Have a play and tell us how you get on :smile:

I think this is quite a common scenario, “thing” and “thing group” … and I am interested in how the best way to deal with it is. “member of” in “thing”. List of “things” in “thing group” or the two way as you have done.

Or at least try to understand the benefits/downsides of each.

Excellent explanation @NigelG , and I love that you also included screenshots.

Do you have an explanation for the other actions (set list, add list, remove list, clear list)?

Good question :slightly_smiling:

I haven’t used them all, so this is a guess !

So let’s think about a Shopping List…Maybe it already has Milk, Bread, Eggs

Set List sets the list items in one list to the items in another.

“No, that is last week’s shopping list, use this one”. (Replace with another list entirely)

Add List appends a List to another List

“Oh, remember we need Soap and Bacon”. (i.e. adds multiple items rather than a single one)

Remove List removes the (matching?) items in one list from the items in another.

“No, we don’t need Milk and Bread”. (i.e. just leave Eggs).

Clear list removes everything from a List.

“Forget shopping, let’s eat out”.

Nice explanation, thank you!

Here’s another dimension, for your thoughts:

  • I have my shopping list, and you have your shopping list
  • If I assign myself an item from your shopping list, it’s removed from yours, and added to mine.

In that scenario, would you do a ‘remove’ action from me, and an ‘add’ action for you?

1 Like

Yup, spot on :slightly_smiling:

You would need two shopping list things (yours and mine) of course. But you could do it all in the same workflow.

1 Like

I have a similar case, but am not getting the result’s that I hoped.
On a given trigger (currently the push of a button) - I want to set the gap field within every session object to be the [ current time minus the latest field that each session object ]

Here is a screen-grab:

So I am doing a Search for all sessions (no constraints) and then trying to set the gap field afterwards, crucially though, using another field from the same thing within the definition.

My issue is that only one instance of session is changed - not every instance found in the search which is what I need. So, I’m guessing that my issue is with the This connector within the ‘Change a field’ line… But I cannot see another possible term that allows me to reference a field within the same thing.

Not sure where I am going wrong, so any help much appreciated!!

That looks right, and should work.

So I wonder if it is the calculation that isn’t working in each case.

How are gap and latest defined ? Assume you are trying to work out the number of seconds/minutes since “latest” ?

If you can share the app publicly that would really help.

Thanks for your reply Nigel - you reassured me I was on the right lines and I am having more luck today.

I think the test that I built was at fault - multiple Sessions linked to each User, and then a Repeating Group that was unhelpfully sorted.

Cheers