In Business Central cloud, I would like the sales order to work this way: When entering a line, it automatically makes a new line below with another item number. That works fine.
When the user change the Quantity field in the first line, it is also automatically updates the other line, it created automatically before. The two lines must have the same value in Quantity.
The problem is that when the Quantity field is changed in the first line, the second line is changed, BUT it is not visible on the screen. And after that, the second line is locked somehow so it is not possible to change it. The cursor cannot get into the fields in that line.
I have all my code in a table extension for Sales Line in the trigger OnAfterModify. Here is the code:
if ... then begin
local procedure CreateDepositLines(SalesLine : Record "Sales Line")
Item: Record Item;
DepositType: Record "Deposit Type";
DepositSalesLine: Record "Sales Line";
DepositSalesLine.Validate("Document Type", SalesLine."Document Type");
DepositSalesLine.Validate("Document No.", SalesLine."Document No.");
DepositSalesLine.Validate("Sell-to Customer No.", SalesLine."Sell-to Customer No.");
DepositSalesLine.Validate("Line No.",SalesLine."Line No." + 1000);
DepositSalesLine.Validate("Location Code", '');
You only have an insert here?
I'd split the code into 2 parts.
A trigger, OnAfterInsert or OnAfterModify, for inserting the second line.
And for updating you should create a procedure that updates the quantity of the second line.
Call that from the OnValidate event of the Quantity field on the page, and after the procedure call you could try CurrPage.Update(true);
That saves the change you just did and refresh the page. (reload the data)
Thank you for your reply.
I am sure, that your suggesting would solve the problem. However, I have got another solution on the Microsoft Forum:
I have moved my code to "Sales Order Subform" OnModifyRecord trigger and have added CurrPage.Update(false); after creating/updating the other record. That solved the problem.
Thanks once again,