So i've made a button that inserts a line into my sales order lines. Now I know that some fields on a line normally get filled in once the saleline number and type are validated. At the moment do do not have this implemented yet in my code to add a line when i click a button.
The code i have now is following:
*This post is locked for comments
Use this
procedure InsertFreightCost(SalesLine: Record "Sales Line"; Price: Decimal; DocType: Option; DocNumb: Code[20]; DocDate: Date);
var
LineNo: Integer;
begin
SalesLine.Reset;
SalesLine.SetRange("Document Type",DocType);
SalesLine.SetRange("Document No.",DocNumb);
if SalesLine.FindLast() then
LineNo := SalesLine."Line No." + 10000
else
LineNo := 10000;
SalesLine.Init();
SalesLine."Document Type" := DocType;
SalesLine."Document No." := DocNumb;
SalesLine."Line No." := LineNo;
SalesLine.Type := SalesLine.Type::"G/L Account";
SalesLine.Validate("No.",'700010');
SalesLine."Description" := 'Selling. - EU';
SalesLine.Validate(Quantity,1);
SalesLine."Unit of Measure Code" := 'PIECES';
SalesLine."Unit Price" := Price;
SalesLine."Line amount" := Price;
SalesLine."Qty. to Ship" := 1;
SalesLine."Qty. to Invoice" := 1;
SalesLine."Shipment Date" := DocDate;
SalesLine."Planned Shipment Date" := DocDate;
SalesLine."Planned Delivery Date" := DocDate;
SalesLine."Qty. to Ship" := 1;
SalesLine."Qty. to Invoice" := 1;
SalesLine."Return Qty. to Receive" := 0;
SalesLine.Insert(True);
end;
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,900 Super User 2024 Season 2
Martin Dráb 229,275 Most Valuable Professional
nmaenpaa 101,156