Hello!
I am currently working with a case where we import Sales Lines from a PDF. Everything works great, but the description on the line is in a different language, so we want to change it to the default language.
Every line No. is of course connected to a product in Business Central.
The tedious way of doing it, is to copy the line No. and insert it again for each line. When the No. is inserted again, it adds all the other information automatically, including description in the correct language.
Therefor, I want to add a button. Every time that button is pressed, I want to go through each of the Sales Lines in that order, and I want to insert the No. again. I suppose it is the Validating part that is crucial to auto-insert every other piece of information.
I have tried this, but it does not seem to do anything, other than displaying the message at the end:
pageextension 50108 SalesOrderSubformExt extends /Sales Order Subform/
{
actions
{
addlast(/O&rder/)
{
action(ValidateNo)
{
ApplicationArea = All;
Caption = 'Validate No.';
trigger OnAction()
var
SalesOrderLine: Record /Sales Line/;
begin
SalesOrderLine.SetRange(/Document Type/, Rec./Document Type/);
SalesOrderLine.SetRange(/Document No./, Rec./No./);
if SalesOrderLine.FindSet() then
repeat
SalesOrderLine.Validate(/No./);
until SalesOrderLine.Next() = 0;
Message('All lines have been validated.');
end;
}
}
}
}
How can I modify my code to achieve the result I want?