First of all, thanks to all who have taken the time to answer my questions, I could not be more appreciative.
I was able to start solving my own problem on Friday, and looking at the answers, I think I am/was on the right path.
this is what i have.
//This runs at the end of INSERT, not Validate.
However, since i still have to handle the modify quantity situation, I figured the easiest way would be to Write a Adjust Quantity Method that runs on the children lines at the end of modify Event. I could filter the recordset with the Type, DocumentNumber, Relating to Line No.
I think i am getting close.
Table1.INIT;
Table1.SETCURRENTKEY(ItemNo, “Province State”);
Table1.SETRANGE(ItemNo,ItemNo);
Table1.SETRANGE(“Province State”,1); //replace 1 by variable when it’s available
IF Table1.FINDSET THEN
REPEAT
IF Table1.“Start Date” <= SalesHeader.“Order Date” THEN
IF Table1.“End Date” >= SalesHeader.“Order Date” THEN
BEGIN
“Category”.INIT;
“Category”.GET(Table1.Category);
“Auto Sales Line”.INIT;
“Auto Sales Line”.“Line No.” := “Line No.” + 10000 + Ctr;
Ctr := Ctr + 10000;
“Auto Sales Line”.“Document Type” := “Document Type”;
“Auto Sales Line”.“Document No.” := “Document No.”;
“Auto Sales Line”.“No.” := “Category”.“GL Account”;
“Auto Sales Line”.Quantity := Quantity;
“Auto Sales Line”.Description := “Category”.Description;
“Auto Sales Line”.“Unit Price” := “Category”.“Unit Price”;
“Auto Sales Line”.“Attached to Line No.” := “Line No.”; //To keep the relationship from the line that created it.
“Auto Sales Line”.Type := 1; //GL Entry = 1
“Auto Sales Line”.“IsAutoLine” := TRUE; //Extra column to identify Auto Entries
“Auto Sales Line”.INSERT(TRUE);
END
UNTIL Table1.NEXT = 0;