Hi Members,
I need to bring a field (data) from sales order to the purchase order using the Codeunit in Business Central. Please suggest me an appropriate solution - with code (using AL code) for the problem.
Thanks and Regards,
Saravanan M
Hi Members,
I need to bring a field (data) from sales order to the purchase order using the Codeunit in Business Central. Please suggest me an appropriate solution - with code (using AL code) for the problem.
Thanks and Regards,
Saravanan M
Hi Lakshmanan,
Thank you very much. This is working.
Dear suvarna,
Yes, I am able to achieve this. I am hereby attaching the code along with this message. I am sure that the code would work efficiently for you in achieveing your requirement.
codeunit 50133 SOtoPO
{
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Purch. Doc. From Sales Doc.", 'OnCreatePurchaseOrderOnAfterPurchaseHeaderSetFilters', '', false, false)]
local procedure Salesordertopurchaseordermessage(SalesHeader: Record "Sales Header"; PurchaseHeader: Record "Purchase Header")
begin
PurchaseHeader."Vendor Order No." := SalesHeader."External Document No.";
PurchaseHeader.Modify(true);
end;
}
Thanks and Regards,
Lakshmanan R
Hi Saravanan,
R u able to do this? Even I also want to pull external document no from sales order into vendor invoice no in purchase order. If u r able to do then please help me with code part? How to do it in VS.
Hi M Saravanan
If you want to do this as a part of the standard functionality for creating purchase order from a sales order you should use the
OnCreatePurchaseHeaderOnBeforeInsert event on codeunit 1314 "Purch. Doc. From Sales Doc.
There you have access to both the sales order and the purchase order.
If you want to pass field to an existing purchase order you will have to decide if it should happen manually. Have the user click on a menu item or if it should happen automatically either when something happens on the sales order or you want a timer based job that keeps all purchase orders updated.
Hi,
Please use OnCreatePurchaseOrderOnAfterPurchaseHeaderSetFilters event from codeunit 1314 "Purch. Doc. From Sales Doc.",
It will help you transfer Sales fields to Purchase header table.
Thanks.
Dear Inge M.Bruvik,
I am trying to bring an extisting field(value) from Sales Order to the Purchase Order. I am looking for a solution to pass a value from the Sales Order and assign the value to a field in Purchase Order. Please do help me out by providing me an appropriate solution to problem.
Thanks and Regards,
Saravanan M
Hi, I think it depends on how you create the purchase order.
If you create a purchase order from Drop Shipments or Special Order, you need to add the code to the relevant event.
If you create a purchase order from a sales order, you need to add code to this process.
If you are creating purchase orders manually, you need to add the associated step actions.
Although these instructions are not very specific, I hope they will give you some hints.
Thanks.
ZHU
Do you want to create new fields on the purchase order table or will you be putting the data into existing fields.
And do you have some examples of the fields you want to collect from the sales order?
André Arnaud de Cal... 291,661 Super User 2024 Season 2
Martin Dráb 230,379 Most Valuable Professional
nmaenpaa 101,156