Page 1 of 1

Save a copy of Master/Detail

Posted: Wed Oct 05, 2022 12:28 am
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?


Re: Save a copy of Master/Detail

Posted: Wed Oct 05, 2022 9:53 am
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....


Re: Save a copy of Master/Detail

Posted: Wed Oct 05, 2022 11:32 am
by konfuzion

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