DYNAMICALLY DELETE ROWS IN SUBFORM 2 BASED ON SUBFORM 1
- I have a purchase order form that contains Purchase Order No and a subform named Purchase Order
- I have a commercial invoice form that contains a subform named Line Items
- In the commercial invoice form, I added a subform named Purchase Order
- In the Purchase Order subform , I added a lookup field that will look up the Purchase Order No from purchase order form
- I created a script, On user input of the look-up field. Every line item associated on that selected Purchase Order No, will be inserted to Line Items subform in Commercial Invoice.
- I already achieved that goal, the challenge for me now is that, when I tried to remove or delete the Purchase Order No in the look up or delete the row, the associated line items from Line Items subform can't be deleted, currently when I tried to remove or change the Purchase Order No, all the line items will be deleted, which is not the goal, I need help on how to handle this scenario. To dynamically delete associated line items based on Purchase Order No.
BELOW IS MY CURRENT SCRIPT , I also attached a recording with this. Thank you
- if(row.PO_Number.isEmpty() == false)
- {
- variable = Purchase_Orders[ID = row.PO_Number];
- values1 = Collection();
- for each elem in variable.Line_Items
- {
- // input.Line_Items.clear();
- row1 = Commercial_Invoices.Line_Items();
- row1.PO_Number_Tracer=variable.PO_Number;
- row1.Description=elem.Item_Name;
- row1.Quantity=elem.Item_Quantity;
- row1.Unit_Price=elem.Item_Unit_Price;
- row1.Amount=elem.Item_Amount;
- values1.insert(row1);
- }
- input.Line_Items.insert(values1);
- }
- else
- {
- input.Line_Items.clear();
- coll = Collection();
- for each rec in input.Line_Items
- {
- if(rec.PO_Number_Tracer != row.PO_Number.toString())
- {
- row1 = Commercial_Invoices.Line_Items();
- row1.PO_Number_Tracer=rec.PO_Number_Tracer;
- coll.insert(row1);
- }
- }
- // input.Line_Items.clear();
- input.Line_Items.insert(coll);
- }
- //Case NO
- count = 1;
- for each rec in input.Line_Items
- {
- rec.No=count;
- count = count + 1;
- }
- count = 1;
- for each rec in input.Line_Items
- {
- rec.Case_Nr=count;
- count = count + 1;
- }