/ X++

[X++] Find doInsert, doUpdate and doDelete with Cross-references (xRef)

In Dynamics AX 2012, cross-references can speed up the development drastically!
Having them running nightly is recommended and almost standard procedure to set this up when installing a new system.

But you'll have no luck finding statements like doUpdate(), doInsert() and doDelete() which manipulates the database directly.
update(), insert() and delete() methods would show in cross-references, but not their direct counterparts.

But wait, there are records in the xRef tables!
They are simply not accessible from the show cross-references context menu because those methods does not exist in the AOT.

With the following job, you can search for those records and find the usages of the methods:

static void xRefFindDirectUpdates(Args _args)
{
    xRefNames      xRefNames;
    xRefReferences xRefRefs;
    
    // find SalesTable.doUpdate() calls
    while select * from xRefNames
        where xRefNames.name == "doUpdate"
            && xRefNames.typeName == "SalesTable"
        join xRefRefs
            where xRefRefs.xRefNameRecId == xRefNames.RecId
    {
        info(strFmt("%1.%2 > %3 [Col: %4 Line: %5]", xRefRefs.typeName(), xRefNames.name, xRefRefs.path(), xRefRefs.Column, xRefRefs.line));
    }
    
    // find SalesTable.doDelete() calls
    while select * from xRefNames
        where xRefNames.name == "doDelete"
            && xRefNames.typeName == "SalesTable"
        join xRefRefs
            where xRefRefs.xRefNameRecId == xRefNames.RecId
    {
        info(strFmt("%1.%2 > %3 [Col: %4 Line: %5]", xRefRefs.typeName(), xRefNames.name, xRefRefs.path(), xRefRefs.Column, xRefRefs.line));
    }
    
    // find SalesTable.doInsert() calls
    while select * from xRefNames
        where xRefNames.name == "doInsert"
            && xRefNames.typeName == "SalesTable"
        join xRefRefs
            where xRefRefs.xRefNameRecId == xRefNames.RecId
    {
        info(strFmt("%1.%2 > %3 [Col: %4 Line: %5]", xRefRefs.typeName(), xRefNames.name, xRefRefs.path(), xRefRefs.Column, xRefRefs.line));
    }
    
}

The output will look like this:
xppFindxRefDo

[X++] Find doInsert, doUpdate and doDelete with Cross-references (xRef)
Share this

Subscribe to robsCode