Search code examples
google-app-maker

Save values from multi select Field


I be an beginner. I have a multiselect field in my app. The values of these field I will be save in an table with the foreign keys from an another table.

I have a widget with 3 forms software, commodity and contract. All tables are connection into each other. App maker create in the backend a new table with key from the software table and a key from the commodity.

I don't now how save the values from the multiselect field in table.

I currently read the values from the multiselect and pass them to the fields above.

I have same screenshots:

Frontend:
Pic1-Frontend

OnValuesEdit: Pic2-OnValuesEdit

Edit:

I have a table, Produkt_Commodity in these table are different values. For instance:Biogas, energy flex, energy fixed. The values from these table Produkt_commodity will be selection on the page software. The datasouce of the page is software. Software have a many – many binding to Produkt_Commodity. In the page software with datascource software is a Form with a datascource software: Produkt_commodity(relation). In this form I have a multiselect with the values from product_commodity. These values are not stored because I don't know which property to write in the value field.

multiselction Field: multiselction Field


Solution

  • For starters I would encourage you to check out the documentation here https://developers.google.com/appmaker/models/relations#data_binding and the sample app they mention here.

    Now there is a couple of changes you will need to implement. Since your page datasource is 'Software' and your 'Software anlegen' form presumably has a datasource of either 'Software' or 'Inherited: Software' I would encourage you to change the datasource for the 'Create Produkt_Commodity' to 'Inherited: Software' also. Then for your multiselect within 'Create Produkt_Commodity' form have a options binding of @datasources.CommodityP.items and a names binding of @datasources.CommodityP..Name and finally a value binding of @datasource.item.Produkt_Commodity.

    Also, I would suggest in your 'Software' datasource setting to prefetch your 'Produkt_Commodity' relation and then also remove the 'Submit' button from the 'Create Produkt_Commodity' form as it is not needed. In fact you could get rid of that entire form and just incorporate your multiselect widget into your 'Software anlegen' form instead with the same bindings I already outlined. Also make sure to remove the onValuesEdit code that you had associated with your multiselect.