Set Default Value of Epicor Fields With Screen Customization
Learn the step-by-step process to set the default value of an Epicor field through screen customizations.
The first step is to open the form you would like to set the default value in using developer mode. When you are in developer mode select Tools -> Customization to bring up the customization dialog.
Next click on the 'Wizards' tab:
And then click on the 'Form Event Wizard':
These events allow us to connect directly into the underlying functionality of the form via connecting to data changes, business object calls, when the form is opened, closed, and much more. For what we are doing, we want to intercept whenever a new record is created and set a value so for the box 'Select Event Type' choose EpiViewNotification. The EpiView is a representation for all of the data that is represented on the form. In the 'Select View/Table (and Field)' box we will select the table that we want to set the default value in. In this cause, I'm modifying the UD01 table.
Next we click the right arrow:
And click the Update All Event Code:
Now click on the Script Editor to see our new code:
At the bottom now, we have a new code block called edvUD01_EpiViewNotification which is our connection to when data changes in the UD01 EpiView. By default it has an if block checking to see if the NotifyType is an AddRow (meaning a new record is created) and that the row is greater than -1. All we need to do is add a statement inside of that second if block telling it what record we want to set to what value. We do this by saying:
view.dataView(args.Row)("Key2") = "Test"
The "Key2" is the field I would like to set and "Test" represents the value that we would like to set it to. It should then look like this:
Save and run your new customization. When you click on the new button, you should now see that Key2 is filled in automatically!