Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

Bringing the field (data) from sales order to purchase order using Code Unit in Business Central

(0) ShareShare
ReportReport
Posted on by 138

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

  • Suvarna Profile Picture
    Suvarna on at
    RE: Bringing the field (data) from sales order to purchase order using Code Unit in Business Central

    Hi Lakshmanan,

    Thank you very much. This is working.

  • Verified answer
    Lakshmanan.R Profile Picture
    Lakshmanan.R 137 on at
    RE: Bringing the field (data) from sales order to purchase order using Code Unit in Business Central

    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

  • Suvarna Profile Picture
    Suvarna on at
    RE: Bringing the field (data) from sales order to purchase order using Code Unit in Business Central

    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.

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 993 Super User 2024 Season 1 on at
    RE: Bringing the field (data) from sales order to purchase order using Code Unit in Business Central

    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.

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,081 Super User 2024 Season 1 on at
    RE: Bringing the field (data) from sales order to purchase order using Code Unit in Business Central

    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.

  • M Saravanan Profile Picture
    M Saravanan 138 on at
    RE: Bringing the field (data) from sales order to purchase order using Code Unit in Business Central

    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

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 75,673 Super User 2024 Season 2 on at
    RE: Bringing the field (data) from sales order to purchase order using Code Unit in Business Central

    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.

    pastedimage1660437875543v1.png

    If you create a purchase order from a sales order, you need to add code to this process.

    pastedimage1660437899587v2.png

    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

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 993 Super User 2024 Season 1 on at
    RE: Bringing the field (data) from sales order to purchase order using Code Unit in Business Central

    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?

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,379 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans