I have been trying to figure out a scenario that splits an order into two orders and divides the lineitems between the orders based on which line items are checked in the line item portal.
I have a portal on the form for the line items, when a box from lineitems table is checked, the field value = yes.
I want to send the checked items to the new order and keep the unchecked lineitmes with the original order.
I created the following code to create the split the order and line items, then loop through the line items per order and delete the appropriate line items based on the checked box value argument (‘Yes’ or Null).
The orders and line items are successfully split, but the line item deletions are inconsistent, and I can’t figure out the trend, it’s as if the “if” statement is not correctly evaluating. I guess it seems like an indexing issue possibly?
This method is run on a FID form.
// Capture Current PSF Number
globals.Text12 = product_sales_order_number;
// Save Checked Items to memory
var lineitems = psforders_to_psforderlineitems;
// Capture the number of records
var count = psforders_to_psforderlineitems.getSize()
//Duplicates and selects a new master record
controller.duplicateRecord();
//loop on previously saved detail records
for (var i = 1; i <= count; i++)
{
//Duplicates the line Items
lineitems.duplicateRecord(i,false,true);
//Assigns the new master primary
lineitems.product_sales_order_number = product_sales_order_number;
}
controller.saveData();
// Capture new PSF Number
globals.Text13 = product_sales_order_number;
// Return to old PSF
controller.find()
product_sales_order_number = globals.Text12;
controller.search()
//Delete Checked Items from original
for (var i = 1; i <= psforders_to_psforderlineitems.getSize(); i++)
{
elements.PSFOrderLineItems.setSelectedIndex(i)
if(psforders_to_psforderlineitems.split_order_check_box == ‘Yes’);
{
psforders_to_psforderlineitems.deleteRecord();
}
}
//Return To New Record
controller.find()
product_sales_order_number = globals.Text13;
controller.search()
//Delete Un-Checked Items from New Order
for (var i = 1; i <= psforders_to_psforderlineitems.getSize(); i++)
{
elements.PSFOrderLineItems.setSelectedIndex(i)
if(psforders_to_psforderlineitems.split_order_check_box == null);
{
psforders_to_psforderlineitems.deleteRecord();
}
}
If anyone sees anything obvious, I could use a push in the right direction, this is driving me nuts.
Thanks,
Erich