0

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.

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50
semantic_c0d3r
  • 819
  • 2
  • 15
  • 31

2 Answers2

2

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

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50
David Lawson
  • 796
  • 3
  • 10
1

I work in Ax2012, and i needed a solution for convert a field group to set. I hope will help.

private Set fieldGroupToSet(TableId _tableId, FieldGroupName _fieldGroupName)
{
    Set             retSet;

    DictTable       dTable;
    DictField       dField;
    DictFieldGroup  dFieldGroup;

    int             fieldId;
    int             counter;
    int             fieldCnt;
    ;

    dTable = new DictTable(_tableId);
    retSet = new Set(Types::String);    
    if (dTable)
    {
        for(counter = 1; counter <= dTable.fieldGroupCnt(); counter++)
        {
            if(_fieldGroupName == dTable.fieldGroup(counter))
            {
                dFieldGroup = new DictFieldGroup(_tableId, _fieldGroupName);
                if(dFieldGroup)
                {
                    for (fieldCnt=1; fieldCnt <= dFieldGroup.numberOfFields(); fieldCnt++)    
                    {
                        fieldId = dFieldGroup.field(fieldCnt);
                        dField = new DictField(_tableId, FieldId);
                        if(dField)
                        {
                            retSet.add(dField.name());
                        }
                    }
                }
            }
        }
    }
    return retSet;
}
FUS
  • 11
  • 1