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.

SaberLogic Blog - Epicor Screen Customization Image 1 - Open form you would like to set Epicor default value

Next click on the 'Wizards' tab:

SaberLogic Blog - Epicor Screen Customization Image 2 - Wizard tab

And then click on the 'Form Event Wizard':

SaberLogic Blog - Epicor Screen Customization Image 3 - Click the 'Form Events 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.

SaberLogic Blog - Epicor Screen Customization Image 4 - Select event type

Next we click the right arrow:

SaberLogic Blog - Epicor Screen Customization Image 5 - Click the right arrow next

And click the Update All Event Code:

SaberLogic Blog - Epicor Screen Customization Image 6 - Click the update all event code

Now click on the Script Editor to see our new code:

SaberLogic Blog - Epicor Screen Customization Image 7 - Click the script editor to see the 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:

SaberLogic Blog - Epicor Screen Customization Image 8

Save and run your new customization. When you click on the new button, you should now see that Key2 is filled in automatically!

SaberLogic Blog - Epicor Screen Customization Image 9 - Save and run your new customization

About the Author