AX – D365FO – Setting Default Values on a New Record in a Grid

Setting default values on a new record in a Grid is a simple task. To do this, you need to override the initValue() method on the Form’s Data Source. Let say I have a Table named tblDefault which contains two fields TheDate, which is a UtcDateTime type, and Who, which is a String type. In my example, I want the TheDate field to default to the current date time, and the Who field to default to the User Id of the current user:

public void initValue()
{
;
super();


// I’ll use the custom function to get the current date/time from here
tblDefault.TheDate = this.Now();
// AX has a built in function to get the current User Id
tblDefault.Who = curUserId();
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s