web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

how to comment line in sales invoice created from job planning lines

(0) ShareShare
ReportReport
Posted on by

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??

c000da44_2D00_cf3e_2D00_444a_2D00_9cb9_2D00_56aad7ad48aa.png

I have the same question (0)
  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,045 Moderator on at
    RE: how to comment line in sales invoice created from job planning lines

    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.

  • Community Member Profile Picture
    on at
    RE: how to comment line in sales invoice created from job planning lines

    I tried with it but still only single line comment is displayed i dont know where i went wrong please guide me

  • Suggested answer
    Nitin Verma Profile Picture
    21,696 Moderator on at
    RE: how to comment line in sales invoice created from job planning lines

    Hi,

    can you please put your code here in text format?

    Thanks.

  • Community Member Profile Picture
    on at
    RE: how to comment line in sales invoice created from job planning lines

    [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 need something like this 

    i am expecting something like this

  • Suggested answer
    Nitin Verma Profile Picture
    21,696 Moderator on at
    RE: how to comment line in sales invoice created from job planning lines

    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;
  • Suggested answer
    Amit Baru Profile Picture
    3,037 on at
    RE: how to comment line in sales invoice created from job planning lines

    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

    www.linkedin.com/.../

  • Community Member Profile Picture
    on at
    RE: how to comment line in sales invoice created from job planning lines

    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]

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Sumit Singh Profile Picture

Sumit Singh 2,674

#2
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 2,580

#3
YUN ZHU Profile Picture

YUN ZHU 2,115 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans