Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

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

Posted on by 769
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/);
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,698 Super User 2024 Season 2 on at
    Conditional validation on releasing a document - pull in data from the customer record
    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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans