Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

How to add additional validation to a standard GP field (and have it work correctly!)

(0) ShareShare
ReportReport
Posted on by 125

Does anyone have any suggestions on how to add extra validation to a standard GP field while doing the following?

  1. Force the user to reenter the value.
  2. Not clear the value that failed validation (the user can edit another table to fix the problem)
  3. Allow standard validation to reexecute even if the entered value does not change.

I'd rather not clear the new value and make the user reenter it. If I did that I'd also need to add a field to store the old value to revert the entry or just clear it. If there is no other method that works well then I might just have to do this anyway.

I've found it's easy enough to add extra validation to any field, in this specific case I'm using the first segment of the customer's sales and COG accounts and the 2nd and 3rd segment from an item for the GL distribution for invoice lines. When the item number on the sop entry form is validated I need to make sure the appropriate GL code exists. If it doesn't, a message is displayed and validation should fail.

ValidateBeforeOriginal(

 

object sender, System.ComponentModel.CancelEventArgs e)

 

This lets you set e.cancel to true but that just stops the standard GP from proceeding. It doesn't stop the navigation to the next field so the LeaveBeforeOriginal and LeaveAfterOriginal will still fire even if you add a focus() command to put the focus back to the field you validated.

The main problem here is that even if you use ForceValidate(true) in either the before or after validation event only your custom validation event fires. Unless the field's value changes the standard GP validation isn't forced by ForceValidate(true). On the order/invoice lines the user is also prompted if they want to replace the item number if ForceValidate(true) is used in the ValidateAfterOriginal event. Even after that the standard validation doesn't work corretly afterwards, i.e. the uom, price, etc. aren't populated.

I can add my validation in the LeaveBeforeOriginal event but that has other problems such as validating when the field hasn't changed. The Leave events fire before the Close events unfortunately so I can't set a flag and avoid firing the Leave events, twice, before the form closes.

*This post is locked for comments

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,387 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans