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 :
Microsoft Dynamics NAV (Archived)

Field Validation Before Saving Sales Header

(0) ShareShare
ReportReport
Posted on by

We have a custom field on the Customer Record . . ."Ship-to Code Required". This is true for customers when their Bill-To Address is not valid for shipping. For these customers, we need to ensure that Ship-to Code<>'' prior to saving the Sales Header. 

In Nav 2.5 we had code in the OnActivateForm() event of the Sales Line subform which forced the user to go back and enter a Ship-to code.  How would I do something similar in Nav 2016?

I tried putting this code in the OnValidate trigger of "Ship-to Code" on the Sales Header table however apparently the trigger executes after "Sell-to Customer No." is entered and I can't get past the validation error so this must not be the right place to check.

IF Cust."Ship-to Code Required" THEN 

ERROR(ShiptoCodeReq);

//ShiptoCodeReq is a text constant I defined

Thanks!

Sandra

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    keoma Profile Picture
    32,729 on at

    add your code to trigger sell-to customer no. - onvalidate.

    you could also try the page - onnewrecord trigger or trigger oninsert in table sales header.

  • Community Member Profile Picture
    on at

    Thanks, I figured out why the OnValidate trigger of "Ship-to Code" didn't work as I expected . . . it's because the OnValidate trigger of "Sell-To Customer No." calls VALIDATE("Ship-to Code",''). This seems very circular to me.

    I also tried the OnNewRecord trigger of the table - apparently it also execute immediately after Sell-To Customer No is entered so I can't move past this field. I want to validate this after the entire header is completed but before sales lines are entered.

    My background is primarily Microsoft Access and in Access, I completely understand the order of events with forms and form controls. This model is very confusing to me. Validate Triggers seem more like events to do other things based on what was just entered rather than actual validation of the new value in the field.

    Any other suggestions? There must be some standard place to put validations that compare values from multiple fields on the same record prior to saving . . . I just can't find it!

  • Verified answer
    Community Member Profile Picture
    on at

    Problem solved - I put it in Codeunit 80 Sales-Post. That works well enough for me.

    Thanks!

    Sandra

  • Suggested answer
    Alexander Ermakov Profile Picture
    28,096 on at

    Also, check Differences Between the Classic Client and RoleTailored Client for OnValidate Trigger: msdn.microsoft.com/.../dd338867.aspx

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 > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans