Duplicating records with children records together

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
wilmira
Veteran Member
Posts: 67
Joined: 2013-07-11 18:00

Duplicating records with children records together

Post by wilmira » 2018-01-09 17:16

In the case of an invoicing solftware, where we have the invoice and its items. Is there a way to duplicate an invoice and automatically duplicate its records?

Sometimes, we just need to duplicate the whole invoice with its items included, maybe because the next invoice contains almost every item of the previous one or maybe the same items, and the only thing that chages is the customer.

I would appreciate any suggestions.

User avatar
Celson Aquino
Posts: 27
Joined: 2017-08-26 15:40
Location: Salvador, Bahia - Brazil

Re: Duplicating records with children records together

Post by Celson Aquino » 2018-01-09 18:21

I think you'll need to use custom code in order to do that. I would take a look at documentation at https://bigprof.com/appgini/help/advanc ... ific-hooks and read the following hooks:

- tablename_after_insert()
- tablename_after_update()

You can add code inside these hooks that will read all records of the children table and, for each record, copy it to the new master table (new invoice).

peebee
AppGini Super Hero
AppGini Super Hero
Posts: 352
Joined: 2013-03-21 04:37

Re: Duplicating records with children records together

Post by peebee » 2018-01-09 23:47

You just want to duplicate an Invoice? Simple solution with no coding?

Is the "Hide 'Save as Copy' when editing records" option unchecked for the invoicing table in Appgini?

If unchecked - you should have a "Save as Copy" button available when editing records. It will duplicate any record. Then just change your customer details?

User avatar
Celson Aquino
Posts: 27
Joined: 2017-08-26 15:40
Location: Salvador, Bahia - Brazil

Re: Duplicating records with children records together

Post by Celson Aquino » 2018-01-10 10:37

Yes, the "Save as Copy" will copy the record but will not copy the children record (on any children table). At least in my test right now, with a generated application (AppGini 5.62) it is just duplicating the record on current table and not on childrens.

wilmira
Veteran Member
Posts: 67
Joined: 2013-07-11 18:00

Re: Duplicating records with children records together

Post by wilmira » 2018-01-10 19:48

Thank you Celson and Peebee,

It would be wonderful if appgini developer could implement this feature.

Of course I had tried before the "Save as Copy" feature, but as Celson says, it won´t copy the children records. Is there a way I can trigger my custom script on a hook when I click over the save as copy button?

Post Reply