We "preload" invoices here all the time. Since our invoices (purchase orders technically) are to redeem used beverage containers, 90% of the items redeemed will be represented by 1 of 4 types so the "preload" part of the script saves our weighmasters a lot of time and enables them to serve customers with great rapidity.
The basic concept is shown in this script that creates a single line item record with a product ID of 1234:
After creating the new invoice, add these lines:
Set Variable [$InvoiceID ; Invoices::InvoiceID ]
Go to Layout [LineItems (LineItems)] //any layout based on the correct table will work as long as there are now layout script triggers that interfere...
Set Field [LineItems::InvoiceID ; $InvoiceID ]
Set Field [LineItems::productID ; 1234 ]
Go To Layout [original layout]
The trick is to get the correct set of line items since you specify that it be "by location". If you can pull up the line item records you want to preload by using a find or go to related records, you can loop through them, popping back and forth between layouts and using variables to convey the needed data to each new line item record.
Great thanks - I will give this a try. What is the significance of the 1234 in line 5?
Phil said: "The basic concept is shown in this script that creates a single line item record with a product ID of 1234"
Keep in mind that the script only illustrates the general concept. Your final working script will have quite a few more added details. If you can't figure those out, let us know and we'll take it to the next step. (We'll need to know more about your database when we get to that part of the process.)
Okay this worked perfectly. I will read up on looping through so I can try to figure out on my own because ultimately I will want to search by region "USA, EUROPE" etc. and then pull the particular line items I'm carrying for that particular region
Thanks very much