copy parent, childs, grandchilds with new ID

Hello everybody. I should create a mechanism where an end user, clicking a button, creates a copy of such organized data.

I have a situation of
parent> many child> any child can have many grand childs.

In practice it should create a new PARENT ROW with a new ID, copy the children with new IDs by inserting the new PARENT ID in the ref column, and copy the grandchilds with new ids by inserting the new PARENT and CHILD ID in the ref columns.

this are tables

2022-07-18 13_18_33-Window.png2022-07-18 13_18_45-Window.png2022-07-18 13_14_26-.png

any suggestion?

Solved Solved
0 12 380
1 ACCEPTED SOLUTION

Aurelien
Google Developer Expert
Google Developer Expert

Hi @bolognesiedalla 

I made sample apps for this purpose.

Here  they are:

PF_Parent_Child_GC_noBot

PF_Parent_Child1_Child2_noBot

This solution requires you to know exactly how many children maximum you can have on the first level.

You may want to combine both ideas in order to get your result.

View solution in original post

12 REPLIES 12

Aurelien
Google Developer Expert
Google Developer Expert

Hi @bolognesiedalla 

I made sample apps for this purpose.

Here  they are:

PF_Parent_Child_GC_noBot

PF_Parent_Child1_Child2_noBot

This solution requires you to know exactly how many children maximum you can have on the first level.

You may want to combine both ideas in order to get your result.

Nice one @Aurelien . I  quickly browsed the apps. You may want to add these apps in the tips and tricks section as well. Especially the one that has both children and grand chidden records.

Hi thank you very much for the links to the two APPs. I had already seen them in a previous post but the links didn't work. I have 2 doubts:

1. How do you fill in the [NextParent] and [Next Child] columns? always with UNIQUE ID ()?

2. How do you fill in the [PreviousChild] column?

3. can you explain better "how many children maximum you can have on the first level"? Why do multiple actions have to be created for each child and grandchild?

Hi @bolognesiedalla 

1) yes

2) this comes from the row from which the action where triggerd. this is the value embedded in [NextParent], for example

3) Let's say you have an item, and related persons, and related warehouses. That makes 2 "children branches".

works great. thanks a lot

Hi!

Your demo app is great and really helped me a lot. Was just wondering if for the demo app child 1&2 (second one), is it possible if I can duplicate any order and not just the latest order as shown in yr demo app.

Hi @bolognesiedalla ,

I think you have asked this question a few times in recent past. Were you able to take a look at the related  tips and tricks posts. Of course those may not have grand children as well. But you could get some ideas.

Search - Google Cloud Community

 

I hadn't actually found something targeted yet. If not Aurelian's post where the links no longer worked. I delete the previous post of request. I apologize if I have created any confusion

Aurelien
Google Developer Expert
Google Developer Expert

Yes, I thought about this when I made these and...forgot as quickly it came to my mind ๐Ÿคฃ

Thank you for the reminder ! 

And thank you for the positive comment !

Hi guys! @Aurelien's solution looks like it should work in my case. I only have one child. I have set up everything exactly as the sample app but I'm getting this error message when I try to duplicate:

 

Action Failed: Parent is required

 

The only other thing I notice that is different from the sample app is that the system has not generated a view ref for Next Child.

Screen Shot 2023-05-09 at 11.59.51 AM.pngScreen Shot 2023-05-09 at 11.54.39 AM.png

 

Any ideas? Appreciate it!

Update here: It is functioning correctly on Mobile but not on Desktop app.

Aurelien
Google Developer Expert
Google Developer Expert

Hi @NoorHakim21 

It's for duplicating any order, not just the last one.

Top Labels in this Space