Search code examples
google-app-maker

Access value from a list row from a script in App Maker


In my main data input in my Google App Maker app, I have relation data that's displayed in a list. I want the entries in that list to be able to be null until the user takes a specific action by clicking on a particular button, but at that point, I want the existence of values to be validated.

For the life of me, I couldn't figure out how to access iterate through the rows in the list and check the value of a specific field. But after a TON of trial and error, I figured it out -- see below.


Solution

  • Starting with the list widget (MyList), get the rows contained in it:

    var rows = MyList.children._values;

    To access the widgets in an individual row, identify them as an array first:

    var widgets = rows[0].children._values;

    Then get the value of the widget you want by identifying by index:

    var value = widgets[0].value;