How to make methods on fields disappear (aka a bug)

  • August 5, 2010
  • 4 Comments

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:

  1. Go tot the AOT and chose a form
  2. Open the [FORM] -> Data Sources -> [TABLE] -> Fields -> [A FIELD] -node
  3. Add a method (for example the modified-method)
  4. Save your form
  5. Go to the properties of the table in the datasource
  6. Place your cursor in the table property (properties window)
  7. 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.

  1. Klaas Deforche left a comment on August 5, 2010 at 8:50 am

    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.

  2. Jeroen Doens left a comment on August 5, 2010 at 9:39 am

    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

  3. Luegisdorf left a comment on August 5, 2010 at 11:43 am

    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.

  4. Klaas Deforche left a comment on August 5, 2010 at 2:20 pm

    @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.

Comments are closed.