Hey guys.
I would like some help. I tried looking in videos and communities, but without success.
I have a table of products that are a set of parts. For example: Product A contains Parts B, C and D from another table. However, I would like to create product B that contains the same parts B, C and D. As a set can have several parts, I wanted to copy Product A with its respective parts and create a Product B only by changing the quantity of parts B, C and D. Is there a way to do this?
Thanks in advance.
It is “possible” but there is no simple way to do it.
Here is an overview of one way that I tried and works.
-
Create a column that records the ID of a parent record that a new record is copied from
-
Do the same (copied from) for the child table
-
Create an ENUMLIST column on the PARENT (appears as [child_qty] in the template below) that holds a list of quantities that apply to each of the child records.
-
Create an action to copy a parent record, making sure that the source ID is copied to the copied_from column of the new record. This action should only be shown if the number of the ENUMLIST equals the number of the related child records
-
Create a AppSheet API bot on an add event of the PARENT table to add/copy child rows which reference the newly created PARENT row using the information created above.
Here is what my template looks like
{
"Action": "Add",
"Properties": {
"Locale": "ja-JP",
"Location": "47.623098, -122.330184",
"Timezone": "Pacific Standard Time",
"RunAsUserEmail": "YourEmail@google.com"
},
"Rows": [<<Start: SELECT(CHILD[child_id],[ref_parent]=[_THISROW].[copied_from])>>
{
"ref_parent": "<<[_THISROW].[parent_id]>>",
"child_description": "<<[child_description]>>",
"copied_from":"<<[child_id]>>",
"qty":"<<INDEX([_THISROW].[copied_from].[child_qty], COUNT(SPLIT(ANY(SPLIT((" , " & [_THISROW].[copied_from].[Related childs] & " , "),(" , " & [child_id] & " , ")))," , ")))>>"
}
<<End>>
]
}
This uses the INDEXOF() technique described here.
If all this looks complex, I suggest you just copy childs using a technique you most likely have already found through your search and edit numbers manually.
Thanks for your suggestion @TeeSee1 .
I’ll try it, and then I’ll come back here and let you know if it worked.