Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

Updating reference in PO created from SO

(0) ShareShare
ReportReport
Posted on by 37

Hi folks,

I'm creating purchase orders from sales orders for items not in stock - that is the normal process in this firm as we don't hold stock of most items, and lead times are short.

When I create the Purchase Order, ideally we'd like to automatically update the PO created to include the Sales Order # in the "Your Reference" field.

I'm unsure how to develop an extension to do that - has anyone else done the same, and able to share the best approach?

Cheers,

Hamish

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,194 Super User 2024 Season 2 on at
    RE: Updating reference in PO created from SO

    You can try the following event

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

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

       begin

           if PurchaseHeader.FindSet() then

               repeat

                   PurchaseHeader."Your Reference" := SalesHeader."No.";

                   PurchaseHeader.Modify();

               until PurchaseHeader.Next() = 0;

       end;

  • Hamish Duff Profile Picture
    Hamish Duff 37 on at
    RE: Updating reference in PO created from SO

    Thanks for the pointer. I'm thinking there must be an event firing when you click Create Purchase Orders, I'm hoping I can use that to insert the reference...

  • Hamish Duff Profile Picture
    Hamish Duff 37 on at
    RE: Updating reference in PO created from SO

    Sure, just the button to create purchase orders under Related, Funtions. Actually I've relocated it to Home for easy access.

  • KasparsSemjonovs Profile Picture
    KasparsSemjonovs 3,962 Super User 2024 Season 2 on at
    RE: Updating reference in PO created from SO

    In standard it is possible, that You create 1 purchase order that is connected to several Sales Orders, so if You want to do it 1 by 1, don't forget to add a check regarding this.

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,194 Super User 2024 Season 2 on at
    RE: Updating reference in PO created from SO

    May I know what action/process are you using to create the 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

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 Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans