How to make methods on fields disappear (aka a bug)
Me and some of my colleagues are currently working with a customer on a Ax 2009 SP1 RU4. The other day we came to the conclusion that the modified methods on fields in a form suddenly disappeared. I know, you should write as less as possible code on a form, but sometimes there is no way around this.
After some research we found a reproduction how these methods suddenly disappeared:
- Go tot the AOT and chose a form
- Open the [FORM] -> Data Sources -> [TABLE] -> Fields -> [A FIELD] -node
- Add a method (for example the modified-method)
- Save your form
- Go to the properties of the table in the datasource
- Place your cursor in the table property (properties window)
- Push ENTER
The result is that the table will be reloaded in the form and all methods you created on the fields will be gone. So here you have another reason why you shouldn’t write lots of code on your forms. You can only lose it by accident.
Tags: Ax 5.0 (2009), Bug, Dynamics AX, Forms, MorphX, Programming
This entry was posted on Thursday, August 5th, 2010 at 06:00 and is filed under Dynamics AX. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.


August 5th, 2010 at 08:50
Hi Jeroen,
The problem is probably that the property AutoDataGroup is set to yes on you field group.
When this is the case, your methods will disappear.
Check out my blog post about this:
http://www.artofcreation.be/2010/01/09/lookup-override-does-not-work/
Regards,
Klaas.
August 5th, 2010 at 09:39
Klaas,
This issue also occurs on the methods in fields in the Data Sources node, so the code applies to all fields of that table in your form.
I didn’t ment the fields in the design node. But the AutoDataGroup can also be a pain in the ass.
Kind regards,
Jeroen
August 5th, 2010 at 11:43
I think that’s not a bug – just missing intelligence of the IDE. If you touch the ‘table’ property, the IDE thinks, you refer to a new table an rebuilds the datasource fields (even yes, if the table is the same as before, this will not be checked …). And the field rebuilding process first kills the old fields with all their methods and their properties. After the fields are re-created, but fully default.
August 5th, 2010 at 14:20
@Jeroen
.
Yes you’re right, the AutoDataGroup property is unrelated to this problem. Code isn’t safe anywhere on a form it seems
@Luegisdorf is correct, it’s probably a missing ‘if’ in the IDE.