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

Announcements

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
    101,995 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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,344 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,742 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,231

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans