Well, we don't know what tables, layouts, scripts and relationships you have already created here...
Wouldn't it make more sense that if all the items on the original invoice are to be backordered, just change the status of that existing invoice to "back ordered"? Your script could check for that possibility before creating a new invoice for back-ordered items.
Hi Phil. Thanks for your response. I'm using the fmstarting point, so my tables, etc are all basically the same.
My script loops through the line items, and moves each as required. If quantiy out is more than stock level, it processes it as a seperate backorder. How can I make it check if all line items are backorders first before processing each line? Thanks.
If I'm asking something that has already been discussed, please advise, but I've searched for hours to no avail.
Use a separate loop that loops through all the lineitems.
Set a variable to False before starting this loop.
IF any record in the loop is for an item that is at least partially instock, set the variable to true and exit the loop.
Then use an If statement that checks this variable's value. If it is false, the entire invoice needs to be back ordered. If it is true proceed with your current looping script and split the invoice into that which can be shipped immediately and that which will be backordered.
Thank you Phil! I'm still a beginner, so sometimes the obvious is not so obvious. I actually solved my problem by keeping the items on the original invoice, just being marked as backordered. If an item is partial shipment, the script just creates a new line order with the backordered amount, of course flagged as a backorder. I then attached a button that will move each item to a new invoice as the product(s) arrive. Seems to be a cleaner approach.