How to obtain the record ID of the selected item i

2019-08-08 19:13发布

Summary

Obtaining the record ID of the selected item in a drop-down list or radio-button UI appears to be a common question, but I have not found the answer for Google AppMaker despite months of searching.

The example use case: is I wish to edit a product that belongs to a family:

Product - (N:1) --> Family

Product - (M:N) --> FeatureValues

Example

The product belongs to the family Credit Card.

The credit-card family has the following features: |Contactles |Near field |Rates |Chip & Pin|

In the edit form if I change the family the product belongs to then the list of features will change and new values for the features will need to be entered. (Dynamic form)

Hierarchy table

The family, features and permitted values are held in a single hierarchy table:

Family | Features | Values

newValue._key appears to only work for text-box UI items.

Dropdown list:

widget.datasource.item.Id or _key provides the Product ID of the parent data source, ProductById (because I am editing a single product)

widget.datasource.selectKey(newValue._key); returns undefined

Sample code

Drop-down-list OnValueChange event:

//update the features drop-down based on the taxonomy family selected app.datasources.TaxonomyChildren.query.parameters.parent_fk = app.datasources.TaxonomyFamilies.item.Id;

app.datasources.TaxonomyChildren.load();

If I can pick up the record ID for the selected family in the dropdown list I can set a query.filter.parameter to show the features and values for the newly selected family.

Note: if it is a case you cannot create 'dynamic' forms in Google app-maker, then I'll stop as this has exhausted a lot of time.

Edit product page showing features of family

0条回答
登录 后发表回答