Copy Parent, Child, Grandchild all to another table with one click?

NCD
Silver 2
Silver 2

 

What would be a good way to achieve this kind of action?

I was able to Copy the ParentArchive to Parent and vice versa by,

Add a new row to another table using values from this row

but can't seem to figure out how to copy the child and grandchild as well ๐Ÿ˜•

untitled (2).png

โ€ƒ

Solved Solved
0 21 558
2 ACCEPTED SOLUTIONS

@Joseph_Seddik 

Thank you always, for helping me out.

This method of yours, it made a duplicate to corresponding tables, but did not have the relationships.

On the other hand

@Aurelien  's method, made it so it copies in the same table.

 

So I've implemented both of your ideas and made it to work.

Duplicating Parent to Grandchild, all to another table

 

Thank you so much for your help, and I'd appreciate it if there are any ways to make it more efficient please tell me! ๐Ÿ™‚

View solution in original post

Yes, for this you'd need to generate new keys. 

View solution in original post

21 REPLIES 21

Check Chained Dereference Expressions

Dereference Expressions | AppSheet Help Center 

Does that solve your problem? 

unfortunately no ๐Ÿ˜ž

These lines are only connected horizontally, not vertically.

The vertical lines are what I want them to happen; copy
sorry for the confusing diagram๐Ÿ˜…

Table 1, columns:

  • ID-1
  • Ref to ID-2

Table 2, columns:

  • ID-2
  • Ref to ID-3

Table 3, columns:

  • ID-3

If you begin with Table 1, then the additional rows to copy should be: 

  • [ID-2]
  • [ID-2].[ID-3]


If you begin in Table 3, the rows to copy should be:

  • [Related Table 2]
  • [Related Table 2][Related Table 3]

 

What kind of Do this behavior would I put this into?

Where do you begin? 

The ParentArchive_Table ๐Ÿ™‚

I've written a table schema in my reply because table references in your diagram are confusing to me. So please either reply based on the schema in my reply, or provide screenshots for the configuration of your tables clearly showing Ref columns. Thank you.

I'm sorry!

I hope this is a little bit easier to see!

untitled (2).png

โ€ƒ

โ€ƒ

Thank you, don't worry. I think you should change the direction of horizontal arrows in your diagram. 

Anyway, last question, are these a one-to-one relationships? or one parent can have more than one child and a child can have more than one grandchild?

Oh I see, thanks for the tip. It confuses me because in Specs in AppSheet the arrows are this way ๐Ÿ˜•

they are all one-to-many relationships!

  1. For each of your tables, create the corresponding copy Action, productCopy, modelCopy, bomCopy
    • Data: add a new row to another table using values from this row
    • Table to add to: corresponding copy table
    • Set these columns: all of them

  2. Create an action actOnModels for your parent ProductArchive table:
    • Data: Execute an Action on a set of Rows
    • Referenced Table: ProductModelArchive
    • Referenced Rows: [Related ProductModelArchive]
    • Referenced Action: modelCopy

  3. Create an action actOnBOMs for your parent ProductArchive table:
    • Data: Execute an Action on a set of Rows
    • Referenced Table: BOMArchive
    • Referenced Rows: [Related ProductModelArchive][Related BOMArchive]
    • Referenced Action: bomCopy

  4. Your final Button Action to perform the copy from the ProductArchive table should be: 
    • Grouped: Execute a sequence of actions
    • Actions: 
      • productCopy
      • actOnModels
      • actOnBOMs

3.

Does not seem to work ๐Ÿ˜ž

I've seen that I made a typo and repeated ProductModelArchive in step no. 3. I edited and corrected it. 

Please correct the Referenced Table in step 3. to be BOMArchive instead of ProductModelArchive.

@Joseph_Seddik 

Thank you always, for helping me out.

This method of yours, it made a duplicate to corresponding tables, but did not have the relationships.

On the other hand

@Aurelien  's method, made it so it copies in the same table.

 

So I've implemented both of your ideas and made it to work.

Duplicating Parent to Grandchild, all to another table

 

Thank you so much for your help, and I'd appreciate it if there are any ways to make it more efficient please tell me! ๐Ÿ™‚

I'm glad you have a working solution ๐Ÿ™‚ 

>> but did not have the relationships

Why is that? If the original tables "have the relationships", why wouldn't the exact copies have them? would you please explain? Thank you!

I'm not familiar with @Aurelien's method; it is not in this post. Would you please get the link? Thanks again. 

Sorry what I meant was, your method creates:

an EXACT duplicate of Every Record to another Table with the same id.

 

What I wanted was, making a duplicate of every record with a new id, and still retain the references with the new ids.

 

Why I wanted create this action, is because most of the NEW products we create, are made up with similar materials that we've used on PAST products.

 

So rather than creating a product from scratch, it's much faster and has less space for error (in our case) if making a duplicate but NEW IDs with an already related Child and Grandchild was achievable.

 

This is @Aurelien 's original reply post, but can't seem to Find the App anymore ๐Ÿ˜•

https://www.googlecloudcommunity.com/gc/AppSheet-Q-A/Duplicate-Parent-with-Child-entries/m-p/382346/...

Hello, I am looking to implement the same thing but the template you created is no longer available. Would you have any advice on how you did it?

I see, thank you.

You wouldn't need new IDs however; since you are creating new tables. Keys have significance only within a table, not across the app tables. 

For example, when I have one-to-one relationship I use the same IDs as keys for the Parent, Child and Grandchild tables, just for convenience. At the same time I have one less column in my table; since my Ref column is also my Key column. 

Yeah, but once I've finished creating that product, I would than again put that back into the Archive to create a from a blank table for faster user experience!

so I would need a different ID ๐Ÿ˜•

 

Hello. I have the same need as you to copy records with 3 hierarchies generating new IDs. Can you summarize the steps you implemented following Aurelien's solution? You would be doing me a great favor. Thank u very much

Yes, for this you'd need to generate new keys. 

Top Labels in this Space