Wednesday, October 28, 2015

AX 2012:Table methods

Table methods using ValidateWrite() ValidateDelete() initValue() ModifiedField() - Microsoft Dynamics AX 2012


initValue()
 Executed when a new record is added..initValue is automatically called from forms.

public void initValue()
{
super();
this.UserId = curuserid();
}

ValidateDelete()
Executed when a record is deleted..validateDelete is automatically called from forms and is used to check whether the current record can be deleted.

public boolean validateDelete()
{
boolean ret;
ret = super();
info(this.AccountNum);
return ret;
}

ValidateWrite()
Executed when a record is written to the database, before the data change is committed in the database.

public boolean validateWrite()
{
boolean ret;
;
if(this.Address != "")
ret = super();
else
warning(" Please fill the address");
return ret;
}

ModifiedField()
Executed when a field is modified in a form or Web form. Use this instead of placing code on the Form Control/Form data source field.

public void modifiedField(fieldId _fieldId)
{
CustTable ct;
;
super(_fieldId);
switch(_fieldId)
{
case fieldNum(Cust_new,AccountNum) :
{
this.Name = CustTable::find(this.AccountNum).Name;
}
break;
}
}

No comments:

Post a Comment

Table browser URL in D365FO

Critical Thinking icon icon by Icons8