Announcements
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
Also, check Differences Between the Classic Client and RoleTailored Client for OnValidate Trigger: msdn.microsoft.com/.../dd338867.aspx
Problem solved - I put it in Codeunit 80 Sales-Post. That works well enough for me.
Thanks!
Sandra
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!
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.
André Arnaud de Cal...
294,259
Super User 2025 Season 1
Martin Dráb
232,988
Most Valuable Professional
nmaenpaa
101,158
Moderator