Introduction
In the process of implementing and maintaining Microsoft Dynamics® AX, many modifications are created and modified while a portion of these are never used by the business. There is a cost associated with leaving obsolete objects in the system, which is most noticeable in an upgrade. If possible, these objects should be removed. There is no single method for identifying obsolete objects, such as unused code, but a combination of the following approaches should help in this process.
Review Usage Data
Usage data is the information Dynamics AX stores to track changes a user makes to the user interface such as hiding a field, or the parameters a report used. Usage data is captured for every object that has user interaction when those objects are utilized, including forms, reports, and classes that run dialogs. This information can help an administrator determine which functional areas system users are employing, and the last time they used them.
The two primary ways of reviewing usage data to determine what objects have been recently used are: 1) running the element usage log query and 2) querying the syslastvalue table.
- The element usage log pulls information from syslastvalue table to show which objects are used. This can be found at Microsoft Dynamics AX > Tools > Development Tools > Application Objects > Element Usage Log.
- Usage data is stored in the syslastvalue table and can be queried using a query similar to the following:
Review SSRS report usage
For implementations where custom SSRS reports are used, the SSRS execution log can determine when individual reports were executed. More information about the SSRS execution log can be found here.
Check if tables related to customizations have data
Review custom tables to verify if they are empty. If so, investigate the tables to see if they are needed. Also, considering there may be features that were originally utilized, but are no longer of use, it is a good idea to include modified dates on all custom tables, and ensure tables are also written.
The following query can be used to efficiently find the number of records per table, although this should be performed after a recent backup of production or during low volume hours.
Check if fields related to modifications have data
Use a query similar to the following to figure out whether custom fields have data. The following query will run very slowly and should be performed in a non-production system.
-- find the list of tables and fields to investigate which have a fielded between
40000 and 60000 indicating they are custom – Note this works before
Microsoft Dynamics AX 2012. After this version the field id ranges
for each layer change and this will affect this query.
Cross References
Use queries on cross references to determine if objects are used by other objects. This will be an iterative process for as you remove objects, more will show up as unused. The process for using cross references should be:
- Update cross references
- Delete an object such as a table
- Review cross references for related object that can be deleted such as extended data types.
- Go to the referenced object such as an extended data type and if this object was only referenced by the deleted table it can be deleted.
- Repeat
Searches Over Projects
When looking for code that has been used, create a project with all modifications to search over. It is faster to search over a project than the entire AOT. There are two approaches to create a project with modifications to a layer. Compared layers can be used to generate a project with all objects in a layer, with the option of only including those objects if they are in a different layer.
The compare layers process can be performed from Microsoft Dynamics AX > Tools > Development Tools > Code upgrade > Compare layers.
Project filters can be used to create a project based on a filtered query. To create a filtered project, follow these steps:
1. Create a new project.
2. Open the new project.
3. Click the filter button.
4. Decide whether to overwrite the current project or append to the current project when adding objects.
5. Decide how the project should be grouped.
6. Click Select.
7. Specify criteria for the project, such as object type or layer.
8. Click OK to close both forms.
Validate With Users
Create a list of all objects that have not been confirmed to be used and have users validate if these functions are indeed applied. To ensure good user feedback, limit this list to the objects you expect to delete, and provide context for the modification such as the menu path to the modification.