Save a copy of Master/Detail

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
konfuzion
User
Posts: 378

Save a copy of Master/Detail

Post by konfuzion »

Currently if I copy a master record I believe it only copies the master record and not the related detail records, I think the code should be put in ADD/COPY server events.

  1. Click Copy Master Record
  2. Save old_ID to session('old_ID')
  3. Rename master record to $OriginalName . " Copy 1"
  4. Click Add
  5. new_ID = session('new_ID')
  6. query for FK using session('old_ID') from DETAIL table
  7. Re-insert old detail records as new detail records with FK using session('new_ID')
  8. Done

Is there any example code or old post that did the above that I can use as reference?


arbei
User
Posts: 9284

Post by arbei »

You may use Master/Detail-Copy, see Tutorial - Master/Detail. If you want to copy a master record only and the detail records will be copied, you need to do it yourself, e.g. you may use Row_Inserted server event and then execute INSERT... SELECT....


konfuzion
User
Posts: 378

Post by konfuzion »

INSERT..SELECT is elegant solution, thank you ^_^


Post Reply