jueves, 23 de mayo de 2013

createrecidindex

I find myself using the createrecidindex property more and more on my tables in AX 2009, perhaps due to my growing experience with the AX 2012 product.  One small omission from the table properties documentation in the MSDN is the actual name of the index - RecId.

static EVE_NewsTemplate find(RefRecId _refRecId, boolean _forUpdate = false)
{
    EVE_NewsTemplate      tbl;
    ;

    if (_refRecId > 0)
    {
        tbl.selectForUpdate(_forUpdate);

        select firstOnly tbl
            index hint RecId
            where tbl.RecId == _refRecId;
    }

    return tbl;
}

Reading the AX 2012 best practices it seems to indicate that there is always an index created on the RecId field.