Axaptapedia is now maintained by AgileCadence For more information please click here.

Table Methods Generator

From Axaptapedia
Jump to: navigation, search

Table Methods Generator is tool for automated creating table methods find(), exist(), checkExist() and txtNotExist(). Because it is Best Practice to create these methods on every table with unique index, that is quite frequent task. This tools tries to minimize developers' handwork.

Table Methods Generator

Download[edit]

Table Methods Generator 0.1

Features[edit]

  • Supports multiple tables in a single run
  • Supports unlimited number of fields in composite indexes
  • Quick access to generated code using Infolog actions
  • Generated methods complies with Best Practices

Usage[edit]

After adding menu item to context menu (see Installation), simply select one or more tables in AOT, open context menu and click on item "Generate table methods". For every table generator tries to find property PrimaryIndex and generate methods find(), exist(), checkExist() and txtNotExist(). Existing methods are skipped. Result is written to Infolog and InfoActions are used for quick access to code or table object.

Installation[edit]

At first, import downloaded XPO file to Dynamics AX. Installation XPO does not contain any standard objects (objects existing in standard application), therefore no conficts through import are expected. On the other hand, integration to context menu must be done manually.

  1. Add menu item DEV_TableMethodsGenerator to menu SysContextMenu
  2. Restrict visibility of menu item by editing SysContextMenu class, method verifyItem(). Job DEV_TMG_installationNotes contains appropriate code.

Detailed description[edit]

Table Methods Generator is tool for automated creating some table methods in Microsoft Dynamics AX enviroment. These methods are used for finding record by primary index or checking existence of the record. Best Practices for Table Methods demands to create them on tables with unique key. These methods are:

  • find()
  • exist()
  • checkExist()
  • txtNotExist()

All these methods are created by the Table Methods Generator. They can be generally used without changes but for txtNotExist() is necessary to create label manually. Generated methods complies with Best Practices for Dynamics AX Development, specifically with best practices for find(), exist() and X++ Layout (see References).

Fields used for searching in the database are defined by index. This index must be set in property PrimaryIndex on proper tables during methods generating.

Existing methods are preserved. Because method checkExist() uses methods exist() and txtNotExist(), compilation issues can appear if these methods already exists and they have another signature then is expected.

Supported Dynamics AX versions[edit]

  • Developed in Dynamics AX 4.0 SP2
  • Tested in Dynamics AX 2009

Using InfoActions[edit]

InfoActions helps user to do actions directly from Infolog. Table Methods Generator uses InfoActions in two different situations:

  1. Error messages: If it is possible, InfoAction is used for opening proper table in AOT. It is particularly useful if you are working with multiple tables.
  2. Methods list: Names of newly created as well as existing methods are written to Infolog. In both cases it is possible to use InfoAction for opening content of the method.

Labels[edit]

Hard-coded English texts are used instead of labels.

Customization[edit]

There is no configuration available for Table Methods Generator. Of course, you can change source code easily. For example, if you do not want to generate checkExist() method, simply remove appropriate line from class DEV_TableMethodsGenerator, method initMethods().

References[edit]