I found this thread earlier today: Duplicating Bill Of Materials (duplicating portal line items) which got me 95% of the way of where I need to be. The only hitch that I had was that the portal line items (in the case for a commercial invoice) have a quantity field that autofills to "2" upon creation of a new record. This means that, while everything else from the invoice line items carries over perfectly to the duplicate record, the quantity for each order can potentially differ (though most orders end up with "2" in the quantity field).
But for those that aren't "2", I'd like to figure out a way to copy the quantities in the portal from the original invoice to carry over to the new record. Wondering if anyone has a good idea how to modify the script that philmodjunk posted in this earlier thread (which worked perfectly other than the quantity problem that I'm having).
Any help or pointers would be much appreciated,
Quantity field is: Invoice pieces::Quantity
Script is attached