Search code examples
axaptadynamics-ax-2009x++

Get fields present within field group [ax 2009]


AX allows one to define Field Group ( E.g. Dimension ) as an Array in Extended Data Types. How do I get the array elements information, such as label and base type?

Code :

 tID = dict.tableName2Id('CustTable');
counter = 0;
dt = new DictTable(tID);
if (dt)
{
    counter = dt.fieldNext(counter);
    while (counter)
    {
        df = dt.fieldObject(counter);
        arrSize = df.arraySize();
        if (df && arrSize > 1)
        {
            // Field group, get array elements and types ??

        }
        counter = dt.fieldNext(counter);
    }
}

Thanks in advance.


Solution

  • I'm not sure what you mean by field group, but every member of the Array is going to be of the same type.

    df.type();
    

    or

    df.TypeId()
    

    Depending on what "type" you are looking for.

    To get the label pass the number of the array element

    for(i=i;i<=arrSize;i++)
    {
        print df.label(i);
    }
    

    Unusually this is well documented in msdn http://msdn.microsoft.com/en-us/library/aa556779(v=ax.50).aspx