Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

How to copy lines of a new Purchase Order to an already existing Purchase Invoice?

Posted on by Microsoft Employee

Hey guys,

how can I copy all lines of a Purchase Order I currently have created to an already existing Purchase Invoice I have created some time ago?

I would like to do that by code.

How can I do this?

Thank you :)

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to copy lines of a new Purchase Order to an already existing Purchase Invoice?

    dynamics365businesscentral  How to copy lines of a new Purchase Order to an already existing Purchase Order Invoice #mohammedhassan

    https://youtu.be/GSTn2XQMQqc

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to copy lines of a new Purchase Order to an already existing Purchase Invoice?

    dynamics365businesscentral  How to copy lines of a new Purchase Order to an already existing Purchase Order Invoice #mohammedhassan

    https://youtu.be/GSTn2XQMQqc

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to copy lines of a new Purchase Order to an already existing Purchase Invoice?

    dynamics 365 business central 01 نسخ مباشر من شئت الاكسيل مباشر الى البرنامج

    https://youtu.be/I6Z-Y0p63Ek

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to copy lines of a new Purchase Order to an already existing Purchase Invoice?

    dynamics 365 business central Direct copying from the excel sheet to the program 02

    https://youtu.be/NEMZ5_Fi2XI

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to copy lines of a new Purchase Order to an already existing Purchase Invoice?

    dynamics 365 business central 2022 wave1 How to use Excel excel copy paste lines [tag:mohammedhassan]

    https://youtu.be/nVWaQTgpbyE

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to copy lines of a new Purchase Order to an already existing Purchase Invoice?
  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to copy lines of a new Purchase Order to an already existing Purchase Invoice?

    Create a new repeat purchase order

    In the navigation pane, go to Modules > Procurement and sourcing > Purchase orders > All purchase orders. First we'll try the option for copying information to a new order.

    Select New.

    In the Vendor account field, enter US-101.

    Select OK.

    On the Action Pane, select Purchase order.

    Select From all. This is the page from which you can copy from existing orders to your order. There are different options for how the lines are copied, and different kinds of documents that you can copy from. We'll look at the options for how lines are copied first.

    Expand the Parameters section.

    The Quantity factor field is useful if you need to use a quantity that is different than the one that's on the order that you're copying from. For instance, if you want to order twice the quantity that's in the lines that you're copying from, you'd type '2' in this field and then the system will add lines where the original quantity has been doubled.

    The Invert sign field also supports changing the ordered quantity by changing the sign of the quantity for order lines that are added. This may be useful if you need to reverse a transaction, by creating order lines that negate the transaction. This option is automatically selected when the page is opened from the Create credit note action.

    The Copy charges option allows you to copy charges to your new order from the document that you're copying the order lines from.

    The Recalculate prices option uses the current prices and discounts rather than copying these from the document that you're copying other information from.

    The Copy precisely option creates an exact copy of the values in all the fields on the order document header and lines. If this option is not selected, default values are used for many of the fields relating to the vendor and products just as if you were creating the new order manually. For example, if the order that you're copying from had overridden the default Invoice account for the vendor, that same Invoice account would be copied to your order. If you didn't select the Copy precisely option, the default Invoice account for the vendor would be used on your order instead.

    The Delete purchase lines option deletes all purchase order lines that already exist on the purchase order that you're copying to, before applying the new lines. Use this option with caution, as it deletes all existing lines without further warning.

    If you use the Copy order header option, you don't need to manually create the header information on your new order. Note that this option will result in default values being used for the fields associated with the vendor. If the document that you're copying from has non-default values that you want to copy, use the Copy precisely option as well.

    There are different document sources that you can copy from, and each has a separate section on this page. For example, the Purchase orders section allows you to copy from existing purchase orders.

    In the Purchase orders section, select the lines you'd like to be copied to your clipboard. It's possible to select additional purchase orders lines from other purchase orders and copy them to your order as well. It's also possible to add lines from other kinds of purchase documents. The next few steps review the different options.

    Expand the Confirmation section. Here you can select purchase order confirmations to copy from. The purchase order confirmations are identified by the associated purchase journal ID or the purchase order ID.

    Expand the Product receipts section. Here you can select product receipt journals to copy from. The product receipt journals are identified by the product receipt voucher or the purchase order ID.

    Expand the Invoices section. Here you can select vendor invoices to copy from. The invoices are identified by the invoice voucher or the purchase order ID.

    Expand the Selected lines or header to be copied section. This view shows a summary of all documents and lines that have been selected to be copied to your order.

    Select OK. The lines that you selected have been copied to your new purchase order.

  • Verified answer
    RE: How to copy lines of a new Purchase Order to an already existing Purchase Invoice?

    Hi Malue,

    This is something that you could do with table  "Purchase Line"

    You have to code something like this : 

    var

    PurchaseOrderLines: Record Purchase Line;

    PurchaseInvoiceLines: Record Purchase Line;

    in your function :

    PurchaseOrderLines.setrange("Document Type",PurchaseOrderLines."Document Type"::Order);

    PurchaseOrderLines.setrange("Document No.",<< Your PO No.>>);

    if PurchaseOrderLines.FindSet then

        repeat

                  PurchaseInvoiceLines.init;

                  PurchaseInvoiceLines.TransferFields(PurchaseOrderLines);

                  PurchaseInvoiceLines."Document Type":=PurchaseInvoiceLines."Document Type"::Invoice;

                  PurchaseInvoiceLines.insert;

        until PurchaseOrderLines.next=0;

    -----------------------------------------

    Best Regards,

    Salah Eddine BENOUALA

    Dynamics NAV & 365 Business Central Consultant

    Please verify my answer, if you find it helpful.

    Doing so you'll show others that there was found a solution and you credit my 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans