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
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;
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...
Sure, just the button to create purchase orders under Related, Funtions. Actually I've relocated it to Home for easy access.
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.
May I know what action/process are you using to create the PO?
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,113 Super User 2024 Season 2
Martin Dráb 229,918 Most Valuable Professional
nmaenpaa 101,156