Skip to main content

Notifications

Announcements

No record found.

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 Microsoft Employee

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 Microsoft Employee 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 21,081 Super User 2024 Season 1 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 Microsoft Employee 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 21,081 Super User 2024 Season 1 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 Microsoft Employee 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 993 Super User 2024 Season 1 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.

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,602 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,340 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans