Tuesday, May 18, 2010

Setting Default Values on a New Record in a Grid

Today is another newbie quick-tip. 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()

// 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();

No comments:

Post a Comment