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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Conditional validation on releasing a document - pull in data from the customer record

(1) ShareShare
ReportReport
Posted on by 10
I am trying to do a conditional validation before releasing a Sales Order. I want to base this off of a field we have created on the customer record, but I don't seem to be able to get the record. I am trying the below, and I get a message that gives me the customer number just fine, but the customer class (or any other customer record I try is coming up empty). I am hoping there is just something simple I am missing, any ideas?
 
CodeUnit 50305 /EventSubscriptions/
{
   [EventSubscriber(ObjectType::Codeunit, Codeunit::/Release Sales Document/, 'OnBeforeReleaseSalesDoc', '', true, true)]
    local procedure ReleaseSalesDocument_OnBeforeReleaseSalesDoc(var SalesHeader: Record /Sales Header/; PreviewMode: Boolean; var IsHandled: Boolean)
    var
    Customer: Record Customer;
    begin
        if SalesHeader./Document Type/ = SalesHeader./Document Type/::/Order/ then
        begin
         
           Customer.get(salesHeader./Sell-to Customer No./);         
       
        message('Customer:' + Customer./No./);
        message('Customer class:' + Customer./Customer Class/);
I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    98,345 Super User 2026 Season 1 on at
    Hi, I tested it and it looks fine. But please note that this is before the status changes to release, not when it is initiated. For example, if there is a Workflow, it will run at the time of approval.
     
    Hope this helps.
    Thanks.
    ZHU

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,986 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,071 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 975 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans