FieldId switch-case on an table’s array-type field

 
Good morning
 
Yesterday, my boss (-1 to Yvan) wanted to switch-case in a tables’s modifiedField() method on a member of a field of an array type. Since ‘fieldNum()’ returns a single fieldId for an array of fields, you need to use the ‘fieldId2Ext’ to get the fieldId of an array member. He had forgotten that. So here is a quick reminder:
 
public server boolean validateField(fieldId _fieldId) //or modifiedField(fieldId _fieldId)
{
    fieldId fldId;
    fieldId fldIdExt;
    int i;
    boolean retVal = super(_fieldId);
    ;
 
    if (retVal)
    {
        fldId = fieldnum(*MyTable*, *MyArrayField*);
        for (i = 1; i <= dimof(this.*MyArrayField*); i++)
        {
            fldIdExt = fieldId2Ext(fldId, i);
            if (fldIdExt == _fieldId)
            {
                //do something
            }
        }
    }
}
This entry was posted in Dynamics Ax 4.0x. Bookmark the permalink.