how to duplicate a subtable using a button
Hi everybody,
I've created a table (Offertes) which has one subtable (Offertelijnen). Using a button, I would like to duplicate the record in the parent table as well as all the records in the child. Using this button, I would like to automatically make some changes to the fields in both the parent record as well as the child record. I'm struggling to achieve this in the child. Can anybody help me? Enclosed is the file.
2 replies
-
Hi
The simplest way is to use the duplicate() function, which also duplicates sub-tables with Composition set to Yes
let a := this; let b := duplicate(a); b.(Datum := today()); b.(Status := 0); b.(Nummer := a.Nummer + 1); openRecord(b)
To achieve this in code without using duplicate (if Compsition is set to No) would require this. I'd use this to allow you to make changes to the child records at the same time.
let a := this; let b := (create Offertes); b.( Datum := today(); Klant := a.Klant; Nummer := a.Nummer + 1; Status := 0; Omschrijving := a.Omschrijving ); for c in a.Offertelijnen do (create Offertelijnen).( Offertes := b; 'Nr.' := c.'Nr.'; Omschrijving := c.Omschrijving; Aantal := c.Aantal; 'EH-prijs' := c.'EH-prijs' ) end; openRecord(b)
Regards John
-
Yes, that does indeed do the trick, thank you !
Content aside
- Status Answered
- 6 mths agoLast active
- 2Replies
- 46Views
-
2
Following