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...
Suggested answer

Copy Sales Order's External Document No into Purchase Order's Vendor Invoice No

(0) ShareShare
ReportReport
Posted on by

Hello,

I am new to Business Central Development and customization. I want to display Sales Order's External Document No into Purchase Order's Vendor Invoice No.

I am creating Purchase Order through Sales Order. When I click on create purchase order that time only I want to collect Sales Order's External Document No and save it on Purchase Order. Or else directly copy this External Document No into Purchase Order's Vendor Invoice No. 

How to do ?

pastedimage1660291912541v3.pngpastedimage1660291970113v4.png

Please help...

I have the same question (0)
  • Suggested answer
    Nitin Verma Profile Picture
    21,698 Moderator on at
    RE: Copy Sales Order's External Document No into Purchase Order's Vendor Invoice No

    Hi,

    You can call Event OnCreatePurchaseHeaderOnBeforeInsert from Codeunit 1314. and pass the sales header field's value to Purchase Header's field.

    pastedimage1660300004370v1.png

    Thanks.

  • Suvarna Profile Picture
    on at
    RE: Copy Sales Order's External Document No into Purchase Order's Vendor Invoice No

    Hi Nitin,

    Thanks for your reply. Can you little bit elaborate how to do it? I am new for development. Please explain step by step that how to call this code unit 1314. Then how to modify it?

  • Suggested answer
    Nitin Verma Profile Picture
    21,698 Moderator on at
    RE: Copy Sales Order's External Document No into Purchase Order's Vendor Invoice No

    Hi,

    Please declare below event in any Codeunit

       [EventSubscriber(ObjectType::Codeunit, Codeunit::"Purch. Doc. From Sales Doc.", 'OnCreatePurchaseHeaderOnBeforeInsert', '', false, false)]

       local procedure OnCreatePurchaseHeaderOnBeforeInsertPurch(var PurchaseHeader: Record "Purchase Header"; SalesHeader: Record "Sales Header"; Vendor: Record Vendor)

       begin

           PurchaseHeader."Vendor Invoice No." := SalesHeader."External Document No.";

       end;

  • Suggested answer
    Ben Baxter Profile Picture
    6,448 Super User 2025 Season 2 on at
    RE: Copy Sales Order's External Document No into Purchase Order's Vendor Invoice No

    This doesn't sound like a good idea.  If you do what you are requesting, you will have no place to record the actual Vendor's invoice number when it comes in.

    If you want to see your Customer's PO number on the Purchase Order, simply add a new field and have the External Doc. No. populate the new field.

  • Suvarna Profile Picture
    on at
    RE: Copy Sales Order's External Document No into Purchase Order's Vendor Invoice No

    Hi Nitin,

    it's giving error : The member referenced by event subscriber 'OnCreatePurchaseHeaderOnBeforeInsertPurch' parameter 'Vendor' is not found.

  • Suggested answer
    Nitin Verma Profile Picture
    21,698 Moderator on at
    RE: Copy Sales Order's External Document No into Purchase Order's Vendor Invoice No

    Hi,

    Please try this.

    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Purch. Doc. From Sales Doc.", 'OnCreatePurchaseHeaderOnBeforeInsert', '', false, false)]

      local procedure OnCreatePurchaseHeaderOnBeforeInsertPurch(var PurchaseHeader: Record "Purchase Header"; SalesHeader: Record "Sales Header")

      begin

          PurchaseHeader."Vendor Invoice No." := SalesHeader."External Document No.";

      end;

  • Suvarna Profile Picture
    on at
    RE: Copy Sales Order's External Document No into Purchase Order's Vendor Invoice No

    Hi Nitin,

    I already tried but then code is not working. External Document no is not fetching in PO.

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,791

#2
YUN ZHU Profile Picture

YUN ZHU 2,091 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 2,090

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans