I really want to thank the community for their support with my annoying newbie questions:
See this thread ( Call an Appscript function that returns a list, create rows in a table from the returned values - #6 by Suvrutt_Gurjar )
I especially want to thank @Suvrutt_Gurjar and @Steve.
The problem was this:
-
We define a record in our App for a customer activity. (Add a row in a table)
-
This triggers an automation (Automation 1) which calls an apps script.
-
The script creates a folder in a shared Google Drive for the files related to that activity, and returns the folder ID that it created.
-
The automation adds the folder ID to the customer activity record (populates a column in the row)
-
-
The customer provides some files to us (out of band) which we upload to the folder created in step 2.
-
We change a column in the customer activity record (from a drop down)
-
This triggers another automation (Automation 2), which calls. another apps Script:
-
this script accepts the folder ID for the customer activity as input
-
it Identifies (recursively) all files in the folder.
-
it ruturns an Array of strings of the form “GOOGLE_FILE_ID:FILE_NAME”.
-
-
The next step in the should accept the List as input and creates one row in a different table for each item in the list:
-
The cells to add to the row are:
-
Customer Activity ID (taken from the row that triggers the automation)
-
Google File ID ( Take the row, split by “:” and take the first item from the split)
-
File Name (Take the row, split by “:” and take the second item from the split
-
-
There are two major challenges:
- It is not possible to directly process data returned from an external appscript. The value returned must be written into a data table.
- There is not a built in looping concept in AppSheets.
I have a sample app template here which solves these problems. I hope this will help anyone else who needs to solve this problem.