Best method is to not copy the record at all, but to link to it's data or just change a status field in your confirmation order table to distinguish records that have been "invoiced" from those that have not.
of course I want to have another serial numbering ... for invoicing,
Why? Why not the same numbering sequence for each?
If you want to use a separate invoices table, just create a new record in the invoices table and put the orderID of the current orderID into this invoice record. That's all you need to make all data in the order confirmation record accessible to your invoices record. You can then define a relationship based on your OrderID for your Invoices table to set up a portal to the same list of related items in the same table that you have already created for your order confirmation layout.
Set Variable [$OrderID ; Value Orders::OrderID]
Go to Layout [Invoices]
Set Field [Invoices::OrderID ; $OrderID]
is all you'd need for a script to accomplish that.
Thank you for reply.
My accountant insists on issuing invoices one-by-one according to date with no gaps in invoice numbers (should be consistent). And, for example Order #3 could be shipped earlier then #1. This is one thing, and another - my order confirmation's specification could be slightly different from final shipment. So, i'll need real "copy". Ah, one more reason: order confirmation could be done for 5 shipments, that should be invoiced one-by-one (again with serial numbers sorted by date). Phew..
Do you have suggestion for my crazy system?
You can generate an invoice serial number "on demand" without having to copy the entire record.
Either way, if you need to copy data (so it can be modified further without chaing the original) you can define matching fields in Invoices and specify the looked up value auto-enter field option to copy the data from Orders into invoices when the above script creates a new record and enters the order ID.
Splitting the line items over several orders could be simple or complex. I'd add a field in the portal for designating each line item to a different shipment by numbering them 1, 2, 3. This field can auto-enter a 1 for single shipment orders so you do not have to do anything extra in that case.
Then a relationship to the line items can be defined as:
Invoices::OrderID = LineItems::OrderID AND
Invoices::ShipmentNumb = LIneItems::ShipmentNumb
You'd then create a serias of Invoice records with the same OrderID but different shipment numbers.
Wow.. seems to be complicated. So, copying of portal rows are indeed complicated thing. I'll try what you suggesting! Thank you! I'll let you know if this helped!
What I have suggested does not copy portal rows--which could be done, I just don't advise it here as that produces two copies of the same data when it does not appear to be necessary.
But this won't be 2 copies, because what I confirm first to my customer doesn't match 95% of all deals with what I supply (this is specific part of my industry). That is why my final invoice is based on confirmation, but it is always adjusted a little bit.
just what doctor ordered! thank you!