Hello all,
The portal Line Items are linked to the Invoice table as you see above.
The new table that I created are called Voided Invoices.
I created a script that it copy entire invoice to the Voided Invoices table whenever the user is delete the invoice record.
However, when it copies the data, it only copy the last row on the invoice, and other invoice details.
Meaning it copied only one Line Item of the portal row.
The script looks something like this:
............................................
set variable: $serviceName; value: Line Items::Service Name
set variable: $regularPrice; value: Line Items::RegularPrice
set variable: $technician; value: Line Items: technician
......................
Go to Layout: Voided Invoices
set field: service name; value: $serviceName
set field: regular price; value: $regularPrice
set field: technician; value: $technician
.............................................................
go back to original layout.
halt script
What's the best way to do this?
This is because whenever you calculate something from a related table:
It only returns the first related record's value.
You would need Go To Related Records, as well as a Loop script step in order to process ALL related records. Otherwise it's just evaluating in the context of your Invoice record, NOT your Line Items.
However, why do you have a separate table completely for voided invoices? It would be much simpler to have a status field in your main invoices with a status of "voided". You're creating more work from yourself that I'm not sure is needed.