Skip to main content
Business Central forum
Answered

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

editSubscribe (0) ShareShare
ReportReport
Posted on by UG Leader

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

  • Community Member Profile Picture
    Community Member UG Leader 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]

  • Suggested answer
    Amit Baru Profile Picture
    Amit Baru 3,025 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/.../

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 20,984 Super User 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;
  • Community Member Profile Picture
    Community Member UG Leader 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
    Nitin Verma 20,984 Super User 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
    Community Member UG Leader 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
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,714 Super User 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.

Helpful resources

Quick Links

What Motivates a Super User?

We know many of you visit the Dynamics 365 Community and Power Platform…

Demystifying Copilot with Sundar…

Industry experts answer burning questions directly from our amazing Community…

Enabling Copilot Case and Conversation…

Agents can easily recap an ongoing chat, transcribe a voice conversation…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 282,978 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 222,562 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,138

Product updates

Dynamics 365 release plans