Tuesday, August 12, 2008

Another useful Editor Script for developers

In AX the principle of upcasting is used quite a lot. Some examples coule be the RunBase hierarchy or the InventMovement class hierarchy. Basically, the base (or super) classes contain the main part of the hierarchy logic, while subclasses only override a couple of methods performing actions specific to this class.

When browsing the AOT, trying to find a specific line of code (debugging without the debugger, basically), you often find yourself in a situation when you lookup a definition of a method from a derived class, and end up in this method of the base class instead (because upcasting was used in the code in question). And every time you need to see the same implementation in the child class, you need to go back to the AOT and open it from there manually.

Well, not any more.
Here is a small editor script, that you can use to navigate to an overridden method of a derived class.

I created 2 versions of the same script, one using xReferences, the second using Dictionary class. The xRef one, generally, works faster once the xRefs for the class hierarchy is updated (happens the first time you use the script). So I am not posting the second script version. If anyone is interested in that version specifically, let me know and I will send you the code.

I made a couple of small changes to the script since my previous post (which I deleted), making it possible to import the script without compilation errors into AX prior to verion 2009. Sorry for that :)

You can copy-paste the code for the script from axaptapedia.com (There is a problem with copying over the code from blogger site directly)

You can read more about Editor Scripts and how to use them here

Enjoy, and get back to me with any comments or suggestions, posting them as comments or e-mailing me directly

5 comments:

  1. Hi there,

    at Axaptapedia there seems to be only the xRef version listed. Can you post the dictionary variant as well? We have some installations without up-to-date xRefs here.

    Greetings,
    Torben

    ReplyDelete
  2. Hi, Torben

    I will post it on Axaptapedia today, under discussion node for the script.

    But you really don't need it, as the xRefs needed for this script to work will be updated automatically on first use on the system.

    ReplyDelete
  3. Here is a direct link to 2 other implementations of the script:
    http://www.axaptapedia.com/Talk:Editor_scripts_OpenOverriddenMethodDef

    ReplyDelete
  4. I am getting error while running the runbase class it says, Error executing code: Wrong type of element at call of ConIns.

    the error thrown on pack method, i try clearing the usage data and then retry it but error doesn't go away.
    i also change the version list.
    Can you please guide me how can i get rid of this error. i used AX 2009.
    reply to shanjaf@gmail.com

    ReplyDelete

Please don't forget to leave your contact details if you expect a reply from me. Thank you