Using a return value that is an array of objects to populate table

The return value of a call to an App Script returns an array of objects in the following format:

[{"a":1,"b":2,"c":3},{"a":1",b":2,"c":3},{"a":1",b":2,"c":3}]

How does one use the return value to populate the rows of  "Table1" with columns "a","b","c"?

0 2 1,495
2 REPLIES 2

I'd recommend processing that in the script itself, either adding the data directly to the source, or sending it through the Appsheet API.

My go to (very high level):

  • Create the JSON AppSheet API body text using your script; this is an easy thing to do over in scripts, with FOR() and what not.
  • You create the JSON array in the script, and return it's .stringify() value
  • Then pass that string to the AppSheet API, and it writes the records to the database.

It looks like you've got the basics there, just a matter of changing the JSON objects you're creating to those for the API add action.

--------------------------------------------------------------------------------

FYI: You CAN specify that the return is an object (in AppSheet, when executing a script from a bot)

  • When you do this, there's a way for you to map what items are what - and use them appropriately in follow-up steps.

668cd74a-fb60-4394-aa5f-f90b44a06757

Then you can use the de-reference formula you see in the gif at the bottom (in blue)

  • [Get answer].[Key]
  • [Get answer] is the name of the step that's calling the script 
  • [Key] is the name of the element you want
  • So [key 2] & [key 3] would get the other values towards the end of the gif

In a follow-up step you can use that formula:

  • MultiTech_0-1682368559207.png
  • This takes the value from [key 3] and writes it into the [Question_Answer] column

 

Top Labels in this Space