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

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
    95,595 Super User 2025 Season 2 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

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,010

#2
Jainam M. Kothari Profile Picture

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

#3
YUN ZHU Profile Picture

YUN ZHU 1,085 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans