Edit Methods in AX 2012
Indicates that the methods return type is to be use to provide information for a field that is used in a form only
We can create edit method on the
1. Table methods
2. Form methods
3. Form datasoruce methods
Take the
new method in the table, and then drag that method into the grid and set data
source properties.
In that field is usercan edit it and accept the values to
the user and save it CustTable.
|
Edit Name name(boolean _set , Name _name) { Name name =
_name; CustTable custTable; ; if(_set) { if(name) { ttsbegin; custTable =
CustTable::find(this.CustAccount,true); custTable.Name =
name; custTable.update(); ttscommit; } } else { name =
CustTable::find(this.CustAccount).Name; } return name; } |
Or
In AX 2009, when reference controls
were not available, in table if there is a relation created on the basis of
recId i.e. there is a child table and it contains the record Id of the parent
Table. When that child table binds to form, (to display and select the user
friendly information from the parent table, lookup controls were used). The record Id of
the user friendly value is saved on the table with the help of the edit
methods.
To give
an example of an edit method, we will create a new field in the CarTable to
hold the mileage of the car and have an edit method in RentalTable that enables
the users to be in the RentalTable form and still edit the field in CarTable.
We'll
create an extended data type of type integer for the new field and call it
Mileage. Then we'll dd the field to the CarTable.
The edit method in RentalTable will
then look like this:
//This material is copyright and is licensed for
the sole use by ALESSANDRO CAROLLO on 18th December, Chapter 4 [ 105 ]
|
edit Mileage mileage(boolean _set,
Mileage value) { Mileage ret; // find the
car records from the car table with update = true carTable = CarTable::find(this.CarId, _set); if (_set) { carTable.Mileage =
value; carTable.update(); ttscommit; } else { ret =
carTable.Mileage; } return ret; } |
Comments
Post a Comment