1
votes

I have a Google App Maker project where I have a Many-To-Many Relation between 2 tables A and B.

I can build a page for table A where I have a table of related B records and add new ones using a dialog.

However, this approach enables me to create new B records and associate them to an A record but how can I make the user able to select an existing B record and associate it to an A record via UI?

I will need to have it work both ways (Select A records from B record page as well).

UPDATE:

I was to accomplish this by creating a separate dialog for selecting existing records which would show all available B records in a table widget with a SELECT button on each row. clicking the button will add the record to the B related records of the A record. However, I know there has to be an automatic way built by Google that will be less work and better design.

Thanks and I appreciate your help.

2

2 Answers

2
votes

Your solution is a good one, another solution, depending on the number of existing records, is to use the multi-select widget. (You can bind the items to B's datasource, and values to the relation on a record in A. But as I mentioned, this only works well if the number of items in B is small.)

Making this easier is something we've been looking in to, the main challenge is the correct UI in this case depends a lot on the kind of app you're writing.

1
votes

It took me a while to figure out the bindings for a multi-select but I think I am right in saying that they are

MultiSelect 

Datasource: inherited: A
Values: @datasource.item.B
Option: @datasource.B.items

With this that Values are/is what you are updating in A(ie. A.B), but the Options you are updating it with are listed in B(ie. B.items).

Devin Taylor is right in his assertion that if you have a lot of records it may not work so well.