How do I query the objects UtilElements and UtilIdElements to fetch correct results?
I am having issues with querying UtilElements and UtilIdElements in Dynamics AX 2009.
Screenshot #1 shows the class SalesFormLetter being present in the layers sys
, syp
, gls
, glp
and cup
. However, when I run the following the code the output displays that the object exists only in the sys
layer. Output of this code is given in screenshot #2.
Am I doing something wrong in this code? I would like to know all the layers in which a given object is pres开发者_Python百科ent.
Thanks in advance.
#AOT
UtilElements utilElements;
UtilIdElements utilIdElements;
;
info('Querying UtilElements...');
while
select utilElements
where utilElements.name == 'SalesFormLetter'
&& utilElements.recordType == UtilElementType::Class
{
info('Layer: ' + enum2str(utilElements.utilLevel) +
', Object type: ' + enum2str(utilElements.recordType));
}
info('Querying UtilIdElements...');
while
select utilIdElements
where utilIdElements.name == 'SalesFormLetter'
&& utilIdElements.recordType == UtilElementType::Class
{
info('Layer: ' + enum2str(utilIdElements.utilLevel) +
', Object type: ' + enum2str(utilIdElements.recordType));
}
Screenshot #1:
Screenshot #2:
There are other element types involved like UtilElementType::ClassStaticMethod
or UtilElementType::ClassInstanceMethod
. Try running this:
static void UtilElementTest(Args _args)
{
UtilElements utilElements;
;
setPrefix('Querying UtilElements...');
while select utilElements
where utilElements.parentId == classNum(SalesFormLetter)
// && utilElements.recordType == UtilElementType::ClassInstanceMethod
&& utilElements.utilLevel != UtilEntryLevel::sys
{
info('Name: ' + utilElements.name +
', Layer: ' + enum2str(utilElements.utilLevel) +
', Object type: ' + enum2str(utilElements.recordType));
}
}
Actually the AOT is cheating a little to highlight the class. The class itself is not changed, but one of its methods is.
精彩评论