which is the best way to transfer data from a record to another record, if the source record has related data that has to be exported too?
For instance: I have an Order form, with Order_LineItems related data.
I want to create an Invoice, so I have to assign the Order’s CustomerID to the newly created invoice (and that’s easy), but I also have to export Order_LineItems into Invoice_LineItems table, then link them to the new invoice.
So, what’s better? A loop? An Import/Export routine (is it possible?) Anything else?
I was facing the same problem. I have chosen for one database: LineItems.
Order form with a relation to this LineItems
and Invoice form with a (other) relation to this Lineitems.
If you want to change an order to an invoice the only thing you have to do is a loop which changes a field (which is part of both relations, in my case) from "order"to “invoice”
If you want to move an order to an invoice you have to make a loop that duplicates each related record, and than change that field from all the duplicates to invoice.
In this case you don’t have to use import/export, which is rather difficult to achieve in Servoy!
HJK:
I was facing the same problem. I have chosen for one database: LineItems.
Order form with a relation to this LineItems
and Invoice form with a (other) relation to this Lineitems.
If you want to change an order to an invoice the only thing you have to do is a loop which changes a field (which is part of both relations, in my case) from "order"to “invoice”
If you want to move an order to an invoice you have to make a loop that duplicates each related record, and than change that field from all the duplicates to invoice.
In this case you don’t have to use import/export, which is rather difficult to achieve in Servoy!
Hope this helps
I was also considering the single table solution, since SQL backend are not particurarly fond of solutions based on import-export, as far as I know.
The reason I was thinking of import-export (or loop) based solutions is that Order-Invoicing systems often breaks the rules (of normalization and others: for instance, it’s possible to have the need to create an Invoice without having an order) and I thought that keeping LineItems separated would save me a bit of problems
But I’ll switch to a single LineItems table: you convinced me
Anyway, if someone has found a way to safely export data from a related table to another, I’d be glad to know how
for instance, it’s possible to have the need to create an Invoice without having an order) and I thought that keeping LineItems separated would save me a bit of problems
This is possible, because you use 2 different relations to the same table!!
for instance, it’s possible to have the need to create an Invoice without having an order) and I thought that keeping LineItems separated would save me a bit of problems
This is possible, because you use 2 different relations to the same table!!
After switching to a single LineItem table solution, I realized that my problems with the Invoice creation loop was related to a strange problem:
if I use the syntax
currentcontroller.recordIndex = currentcontroller.getMaxRecordIndex() + 1
(see Servoy Advanced Programming Guide for FM Developers, page 180)
the “Go to the Next Record” function doesn’t work.
Replacing it with:
currentcontroller.recordIndex++
The loop works fine.
Is it a know behaviour, a bug o something strange only happening to me?
will be completely ignored. Because you can’t set a record index past the maxRecordIndex (that’s why it is called maxrecord index)
But what are you trying to do? Jump very vast to the REAL last record, because maxRecordIndex only returns 200 the first time if there are more then 200 records?
If you want to de that then just do this in a loop:
will be completely ignored. Because you can’t set a record index past the maxRecordIndex (that’s why it is called maxrecord index)
But what are you trying to do? Jump very vast to the REAL last record, because maxRecordIndex only returns 200 the first time if there are more then 200 records?
No. I just intended to go to the next record, following what’s written on page 180 of Servoy Advanced Programming Guide for FileMaker Developers
Seems like that might be easier than exporting - importing, or altering your schema.
Riccardino wrote:
"which is the best way to transfer data from a record to another record, if the source record has related data that has to be exported too?
For instance: I have an Order form, with Order_LineItems related data.
I want to create an Invoice, so I have to assign the Order’s CustomerID to the newly created invoice (and that’s easy), but I also have to export Order_LineItems into Invoice_LineItems table, then link them to the new invoice.
So, what’s better? A loop? An Import/Export routine (is it possible?) Anything else?"