E10 C# Form Customization - Validate a UD field text

I am trying to setup a field verification on the Project Form that will validate the CustID_c (Project_UD) field to make sure that it is a Valid Customer.CustID.

What is the best way to do this?

I have tried to use Leave and Before/AfterFieldChange. But the problem is that if I am purposely typing an incorrect ID in multiple times then it will just send the error message multiple times in one.

I want the ability to push the Search Button for the Customer and I have that working, but I also want the ability to type in a CustID, but want it to validate that it is a correct Customer.CustID or it will give an exception. I can get the message to pop up, but it still does some interruption for the entire form process.

Any help on the best/simplest process here?

I try to do data validation in BPMs. That will protect data coming from a screen or DMT or even REST. Screen customizations are good for lookups, etc. but the BPM is my gate keeper for data. Just my humble opinion.

1 Like

Thank you, I ended up doing Leave approach and I have it working. If you need this as a reference then let me know.

Just a couple of quick question Bobby:

CustNum is already on Project Contract tab. Is this a different customer than the Contract one?

CustID can be changed in Customer Maintenance. Are you concerned that this will break the link in the CustID_c field?

You can (and should - it’s the reason it exists) use the .Validating event on the textbox. It’s not listed in the wizards but nothing stops you from binding to it:

// In Form.Load or InitializeCustomCode():
txtProjectCustId.Validating += txtProjectCustID_Validating;

// In DestroyCustomCode():
txtProjectCustId.Validating -= txtProjectCustID_Validating;

// In your script:
private void txtProjectCustID_Validating(object sender, CancelEventArgs e)
{
	// Validate your CustID here and if it fails:
	e.Cancel = true;
}

More info here: Control.Validating Event (System.Windows.Forms) | Microsoft Learn

agree with @Mark_Wonsil… a BPM is the most foolproof way AND it is easier later on with upgrades. No need to merge UI Customizations.

Epicor has nice features and sometimes they are not used.

Maybe BAQ Zone would be a nice feature here… You still keep your validation the way you want.

Just a tought.

1 Like

I see Project.ConCustNum but the Contract Customer is different from that of the Project Customer and there is not a Project.CustNum that I see.

The problem with working with a BPM is that there is not a business object set to immediately catch a UD field on a table. We want to inform the user immediately upon data entry rather than waiting until a Save or something. So this won’t work either for a UD column.

We had the same. For us, the Order held the Customer that we we’re selling to but the Contract Customer was the “End User” or where we were ultimately installing.

This is where @Louis_Fequet suggestion of using the validate event to check the field value would come into play. Also, using a search instead of allowing freeform entry prevents errors in the first place. Just something to think about.

But a search involves clicks, and there’s nothing a data entry person hates more than having to use that pesky mouse, when a few tabs would be so much faster… :slight_smile:

The code I posted above will work fine to validate a text box immediately.