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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

How to create 100 purchase orders

(0) ShareShare
ReportReport
Posted on by 2

Hi All,

       I want to create a 100 purchase orders with the same vendor and same item, can anyone help me

Thanks & Regards,

Sams.

  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    Hi,

    I would recommend you please go with Config. Package., Export the excel, fill out all the information and Import it back.

    pastedimage1663312121353v1.png

  • Satish Profile Picture
    2 on at

    Hi Nithin,

             But I have to get those 100 purchase orders by using the AL.

    Thanks & Regards.

  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    Not sure I am understand you question.

  • Satish Profile Picture
    2 on at

    Hi Nithin,

                I have to create a 100 purchase orders with the one vendor and one item only, this has to be done by the reports, but my question is how to create the purchase order.

  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    Hi,

    In that case you can create a CSV file with putting your Header and Line data in it, and then import that CSV file directly from Report using CSV import.

    You can go with XML port creation

    docs.microsoft.com/.../devenv-xmlport-object

    Import CSV file using XML port

    www.hougaard.com/.../

    divyeshchittenavbc.wordpress.com/.../

  • Suggested answer
    Amit Baru Profile Picture
    3,043 on at

    Hi,

    Use the below code for reference.

    report 50230 MyReport
    {
        UsageCategory = ReportsAndAnalysis;
        ApplicationArea = All;
        ProcessingOnly = Yes;

        dataset
        {
            dataitem(DataItemName; Integer)
            {
                //SourceTable =
                trigger OnAfterGetRecord()
                var
                    PurchaseHeader: Record "Purchase Header";
                    PurchaseLine: Record "Purchase Line";
                    GetVendorNo: code[20];
                    GetLocation: code[20];
                begin
                    for i := 1 to 100 do begin
                        PurchaseHeader.init;
                        PurchaseHeader."Document Type" := PurchaseHeader."Document Type"::Order;
                        PurchaseHeader."No" := '';
                        PurchaseHeader.Insert(True);
                        PurchaseHeader.Validate(Buy - From Vendor No.",GetVendor);
                        PurchaseHeader.Validate("Posting Date", Workdate);
                        PurchaseHeader.Validate("Location Code", GetLocation);
                        DocumentNo := PurchaseHeader."No";
                        if PurchaseHeader.Modify then begin
                            PurchaseLine.Init;
                            PurchaseLine."Document Type" := PurchaseLine."Document Type"::Order;
                            PurchaseLine."Document No." := DocumentNo;
                            PurchaseLine."Line No." += 10000;
                            PurchaseLine.Insert;
                        end;

                    end;
                end;
            }
        }

        requestpage
        {
            layout
            {
                area(Content)
                {
                    group(GroupName)
                    {
                        field(Name; GetVendorNo)
                        {
                            ApplicationArea = All;

                        }
                    }
                }
            }

        }

        var
            myInt: Integer;
    }
    Regards
    Amit Sharma
  • Satish Profile Picture
    2 on at

    Hi All,

          I am using this code for creation of 100 purchase orders in a report,

              trigger OnAfterGetRecord()

               var

                   PurchaseHeader: Record "Purchase Header";

                   PurchaseLine: Record "Purchase Line";

                   Vendor: Record Vendor;

                   GetVendorNo: code[20];

                   GetLocation: code[20];

                   DocumentNo: Code[20];

                   i: Integer;

               begin

                   for i := 1 to 100 do begin

                       PurchaseHeader.init();

                       PurchaseHeader."Document Type" := PurchaseHeader."Document Type"::Order;

                       PurchaseHeader."No." := '20000';

                       // PurchaseHeader.Insert(True);

                       PurchaseHeader.Validate("Buy-From Vendor No.", Vendor."No.");

                       PurchaseHeader.Validate("Posting Date", Workdate);

                       PurchaseHeader.Validate("Location Code", GetLocation);

                       PurchaseHeader."Vendor Posting Group" := Vendor."Vendor Posting Group";

                       // DocumentNo := PurchaseHeader."No.";

                       if not PurchaseHeader.Insert() then

                           PurchaseHeader.Modify;

                       PurchaseLine.Init();

                       PurchaseLine."Document Type" := PurchaseLine."Document Type"::Order;

                       PurchaseLine."Document No." := PurchaseHeader."No.";

                       PurchaseLine."Line No." := 10000;

                       PurchaseLine.Insert();

                   end;

                       But I am getting an error I am attaching the error, can anyone help me.

    pastedimage1663412537397v2.png

    Thanks & Regards,

    Sams

  • Suggested answer
    Amit Baru Profile Picture
    3,043 on at

    Hi,

    Pls Assign Vendor Posting Group in Vendor. My given code is correct. This is setup issue.

  • Satish Profile Picture
    2 on at

    Hi All,

            I have set the Vednor posting group and all, but I am getting this error, can anyone tell me what is this error and how to solve this error.

               pastedimage1663477136129v1.png

  • Suggested answer
    IB-29041624-0 Profile Picture
    1,191 Moderator on at

    It looks like you are trying to modify the System Id in your code. And that is not allowed.

    Maybe you can share your code so we can give you more efficient help?

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 796 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 481 Super User 2026 Season 2

#3
AndrewThomas81 Profile Picture

AndrewThomas81 377 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans