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

Announcements

News and Announcements icon
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,812 Moderator on at

    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

    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,812 Moderator on at

    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
    7,178 Super User 2026 Season 2 on at

    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

    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,812 Moderator on at

    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

    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

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 July Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 548 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 417 Super User 2026 Season 2

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 377 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans