by subscribing this event i only got one command line in the sales invoice but i need to have multiple comment lines in sales invoice.
if the job planning lines description is equal to sales invoice then the item should not be printed?? any idea??
by subscribing this event i only got one command line in the sales invoice but i need to have multiple comment lines in sales invoice.
if the job planning lines description is equal to sales invoice then the item should not be printed?? any idea??
how can i make sure that following function insert additional comment lines when OldInvoiceDescription <> '' AND OldInvoiceDescription <> Invoice Description
any guess!!
here
[old invoicedescription=last invoice description]
Hi,
for this first find the Item in Sales Line and add second line of comment, only adding Existing Sales Line No. + 10. in this way you will the requirement.
Regards
Amit Sharma
www.erpconsultors.com
Hi,
Please check this if it works for you.
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Job Create-Invoice", 'OnAfterCreateSalesLine', '', false, false)]
local procedure OnAfterCreateSalesLineAddCommentLine(Job: Record Job; SalesHeader: Record "Sales Header"; var SalesLine: Record "Sales Line"; var JobPlanningLine: Record "Job Planning Line")
var
SalesLineL: Record "Sales Line";
LineNo: Integer;
begin
LineNo := 10000;
SalesLineL.Reset();
//SalesLine.SetRange(Description, SalesLine.Description);
SalesLineL.SetRange("Document Type", SalesLine."Document Type");
SalesLineL.SetRange("Document No.", SalesLine."Document No.");
if SalesLineL.FindLast() then
LineNo := SalesLineL."Line No." + 10000;
SalesLineL.Init();
SalesLineL."Document Type" := Enum::"Sales Document Type"::Invoice;
SalesLineL."Document No." := SalesLine."Document No.";
SalesLineL."Line No." := LineNo;
SalesLineL.Insert(true);
SalesLineL.Type := Enum::"Sales Line Type"::" ";
SalesLineL.Description := JobPlanningLine."Invoice Description";
SalesLineL.Modify(true);
end;
|
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Job Create-Invoice", 'OnAfterCreateSalesLine', '', false, false)]
local procedure OnAfterCreateSalesLineAddCommentLine(Job: Record Job; SalesHeader: Record "Sales Header"; var SalesLine: Record "Sales Line"; var JobPlanningLine: Record "Job Planning Line")
var
SalesLineL: Record "Sales Line";
begin
if SalesLine."Line No." = 10000
then begin
SalesLine.SetRange(Description, SalesLine.Description);
SalesLineL.SetRange("Document Type", SalesLine."Document Type");
SalesLineL.SetRange("Document No.", SalesLine."Document No.");
SalesLineL.Setfilter("Line No.", '5000');
if not SalesLineL.FindFirst() then begin
SalesLineL.Init();
SalesLineL."Document Type" := Enum::"Sales Document Type"::Invoice;
SalesLineL."Document No." := SalesLine."Document No.";
SalesLineL.Insert(true);
SalesLineL.Type := Enum::"Sales Line Type"::" ";
SalesLineL.Description := JobPlanningLine."Invoice Description";
SalesLineL.Modify(true);
end;
end;
end;
//
please guide me where i went wrong
i am expecting something like this
Hi,
can you please put your code here in text format?
Thanks.
I tried with it but still only single line comment is displayed i dont know where i went wrong please guide me
You have to add Line number to your Comment lines.
The way you do it now you will only get one line.
For each line you want to insert you need to increase the line no.
SalesLine. "Line No" := LineNo
And before the next insert of a line you must say LineNo +=100; or what ever span you want between the lines.
By default BC adds 10000 for each line so the first line in your sales order will have line no. 10000 the next one 20000 and so on.
This is because it should be possible to insert lines in between.
André Arnaud de Cal... 291,602 Super User 2024 Season 2
Martin Dráb 230,340 Most Valuable Professional
nmaenpaa 101,156