Am I going the right way. My idea is to get information of fields like name, data-type and if it is a primary key without writing any code in X++. Can I fetch this information using only Axapta class in .NET Business connector?
The .NET example expects that you’re able to get value (I used your own code to demonstrate GetType()). If you don’t know how to get value, you can’t ask for its type, of course.
fieldNext() is not a static method, you have to create an instance of the DictTable first. Your code can’t work even theoretically, because it doesn’t say for what table fields should be obtained. I really recommend testing your code in X++ editor first, it would be refused by compiler.
By the way, what version of AX do you use? You have some other ways in AX2012.
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);
}
}
But i’m getting a Types Enumeration value. ( an integer). How do I get the value in string? e.g. any method like “str fieldType = getFieldTypeName(type_id)” ??
If you want information about extended data types and enums, don’t use baseType() - use type() together with typeId(), enumId(), extendedTypeId2name() and enumId2name(), for example.