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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Business Central Development - How do I programmatically set Purchase Order Description to Sales Order Description?

(0) ShareShare
ReportReport
Posted on by 5

I have been a software developer, working mainly with Visual FoxPro and C# for over 20 years.

Recently, I was asked by a customer if I could develop a simple solution for Business Central.  I have since followed all the relevant courses on AL programming for Business Central within Microsoft Learning and so I am now trying to write the solution.

The customer simply wants the description entered on each Sales Order line to be copied to the corresponding Purchase Order line.  The standard system populates the Purchase Order description from the Vendor product record.

Using Shift+Alt+E in Visual Studio Code, I found what appeared to be an ideal Event, and created the code below:

    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Purch. Doc. From Sales Doc.", 'OnCopySalesLinesToPurchaseLinesOnBeforeInsert', '', true, true)]
    local procedure OnCopySalesLinesToPurchaseLinesOnBeforeInsert(var PurchaseLine: Record "Purchase Line"; SalesLine: Record "Sales Line");
    begin
        PurchaseLine.Description := SalesLine.Description;
    end;

I deployed this to my sandbox to test, but it did not work.  I added a Message() and this did not appear.

I used the Event Recorder to check whether the event was firing after selecting Actions - Functions - Create Purchase Document - Create Purchase Orders from the Sales Order.  The "Purch. Doc. from Sales Doc." event/codeunit did not appear.

I tried subscribing to several other events.  These did fire, and I was able to display test messages to confirm that my code was deploying correctly.  However, I could not find another event where both the Sales Line and Purchase Line were both available.  Also, even if I tried to update the Purchase Line description, this did not change what appeared on the created Purchase Order.

As this is my first Business Central project, I really don't know whether I am doing something wrong, or if this is a bug with Business Central, or something else!

The Business Central version is shown as below in Troubleshooting:

Version: GB Business Central 19.2 (Platform 19.0.32956.35068 + Application 19.2.32968.33612)

I would greatly appreciate any help at all.  Thanks in advance.

I have the same question (0)
  • Suggested answer
    Marco Mels Profile Picture
    on at

    Hello,

    We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist. If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    dynamicsuser.net/.../developers

    I will open this up to the community in case they have something to add.

    Thanks.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,229

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,867 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,153 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans