Find unused EDT’s in Dynamics Ax


To find unused EDT’s in your Dynamics Ax application, the following code will sscan through the crossreference and display the EDT’s on screen.

Note, you will have to compile your application with crossreference turned on, otherwise you may get all your EDT’s as not used 🙂

//True if used
private boolean FindEDTUsed(extendedTypeId _id, str 40 name)
{
XRefNames   xRefName;
boolean ret = true;
;
//select firstonly xRefName where xRefName.kind == xRefKind::ExtendedType;

select firstonly xRefName
where xRefName.kind == xRefkind::ExtendedType
&& (xRefName.name == name);
//|| xRefName.typeName == name);
if(xRefName.RecId)
ret = true;
else
ret = false;
return ret;
}

public void run()
{
Dictionary dict = new Dictionary();
int types;
int i;
int first = true;
Set         unusedEDT;
;
unusedEDT = new Set(Types::Integer);
//Find list of EDT
types = dict.typeCnt();
info(dict.typeName(dict.typeCnt2Id(1)));
/*for(i = 11; i <= 20; i++)
{
info(dict.typeName(dict.typeCnt2Id(i)));
info(strfmt("%1 %2", dict.typeCnt2Id(i), ""));
}*/

for(i = 1; i <= types; i++)
{
//process each type
if(!this.FindEDTUsed(dict.typeCnt2Id(i), dict.typeName(dict.typeCnt2Id(i))))
{
if(first == true)
{
info('Unused EDT List');
first = false;
}
//unusedEDT.add(dict.typeCnt2Id(i)); //store it in a set for later use
info(dict.typeName(dict.typeCnt2Id(i)));
}
}
}
Advertisements

One thought on “Find unused EDT’s in Dynamics Ax

Leave a Reply / Comment

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s