Edit method

Hi all,

Can any body give the detail description about how to run the Editmethod in ax…with example…from the basic steps…clearly

Have you looked into documentation: MSDN: Using the edit Method Modifier?

yes but i dont get any idea

Can u say briefly…?? How to Run the EditMethod

Are you familiar with display methods? You can bind a form control to a display method, therefore when the value should be displayed, AX calls the method rather than reading the value from database. This is for displaying only, you can edit the value.

Edit methods work exactly as display methods, except the fact that you can also edit the value. When you edit the form control, edit method is called and you can do something with the value in code, e.g. saving it in a collection object.

You “run” an edit method by opening or refreshing a form (edit method is called so you can see the data it returns) and by editing the value (edit method is called so AX can do something with the user input).

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;
}
Can u Say how It is Run??

When i try to give DateMethod name in the form .it will disabled??

Which part don’t you understand?

Nevertheless note that running a separate database query every time a value should be displayed is a potential performance killer. Avoid using display/edit methods for such things, unless absolutely necessary. I’ve seen several implementations where display methods were the performance problem number one.

You can simply use the Name field directly instead of this edit method, which will be easier, faster and it will allow removing name (this case would be ignored by the method).

Please, let me remind you that we can’t read your mind - you have to explain your situation properly. “When i try to give DateMethod name in the form” doesn’t explain what exactly are you doing. There may be many reasons.

when i try to add the Editmethod Field in dataSource It Wont Enable…

That’s correct. You can’t bind a single control to both a field and a method. If you want to use the method, delete the value from the DataField property.

look at my sample: metinemreenglish.blogspot.com.tr/…/axapta-edit-method-sample.html . At the “this.ServiceObjectId =
SMAServiceObjectTable::findItem(_ItemId).ServiceObjectId;” line I fill the table field and “ret = SMAServiceObjectTable::find(this.ServiceObjectId).ItemId;” read from table.

1 Like

@bilgates, I see you’re asking new question. Could you please either close this thread (by verifying the answer(s)) or explain what you need before the thread can be closed? Also, please do it with your other threads, as I already asked you before. Many thanks. Your moderator.