I would like to copy an entire row, including...

workflow
(Hugo César) #1

I would like to copy an entire row, including its child-records, without going through a form.

I can add the parent-records via API. For the child-record, I can do that if it is a fixed number. i.e., for 3 rows, make a function with SELECT and INDEX for position 1, 2 and 3.

If its not a fixed number of child-records, to select on child-table and add each child-record I think would need some kind of loop function on the HTTP body.

Is it possible to do that? How can I do it?

(Marc Dillon) #2

Check this article to see if it’ll help you out. help.appsheet.com - Template Start Expressions Template Start Expressions help.appsheet.com

(Reza Raoofi) #3

Agree with Marc; also this document says you could use <> tag in JSON Template for invoking AppSheet API: help.appsheet.com - Invoking Webhooks from a Workflow Rule or Scheduled Report Invoking Webhooks from a Workflow Rule or Scheduled Report help.appsheet.com

(Hugo César) #4

Hello!

I’ve tried start expressions but I haven’t been able to make it work.

The API url requests the {tableName}, it will only make changes to this table, so I created 2 webhook workflows, one for the parent table and one for the child table, both triggered by the same event on the parent table.

The one for the parent table works fine. For the child table, I made the JSON template below, but on the audit log I always find this error:

“ResultError”: “REST API REST API invoke request failed: No API ‘Rows’ are present.”,

Maybe is the way I wrote it. The position of the "[]"s and "{}"s might be wrong. I’ve used Start Expressions for pdf templates, but for JSON I haven’t figured out how to use and the links I found doesn’t say much about it.

{

“Action”: “Add”,

“Properties”: {

“Locale”: “pt-BR”,

“Timezone”: “UTC”

},

<<Start: [Parent_key].[Related Childs]>>

{

“Rows”: [

{

“Collumn1”: “<<[Collumn1]>>”,

“Collumn2”: “<<[Collumn2]>>”,

}

]

}

<> }

(Marc Dillon) #5

Maybe put the <> expression inside of the Rows bracket. Like this:

Rows [ <> {"“col”:“val”,“col2”:“val2” }, <>]

As you have it now, the Row property of the http body is being repeated for every child record, you just want the repetition to be for your column & value settings.