Search code examples
axaptadynamics-ax-2009ax

Field type returning numbers [Axapta]


I want to get the field types. My code is as follows:

tID = dict.tableName2Id(tableName);
counter = 0;
dt = new DictTable(tID);
if (dt)
{
    counter = dt.fieldNext(counter);
    while (counter)
    {
        df = dt.fieldObject(counter);
        if (df)
        {
            fields = conIns(fields,1,df.baseType());

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

On return to .NET Business connector, the types are shown as numbers instead of strings. Kindly help.

EDIT : DataField.baseType() returns "Types" can this be converted to string and then added to the container?

EDIT 2: Ok now, im getting a Types Enumeration. Is there any way to map this enumeration in AX and add to container as string?


Solution

  • Got it!! Here's the code :

    tID = dict.tableName2Id(tableName);
    counter = 0;
    dt = new DictTable(tID);
    if (dt)
    {
        counter = dt.fieldNext(counter);
        while (counter)
        {
            df = dt.fieldObject(counter);
            if (df)
            {
                t = df.baseType();
                fields = conIns(fields,1,enum2str(t));
    
            }
            counter = dt.fieldNext(counter);
        }
    }