2

AX 允许定义数组,但在通过 .NET Business Connector 获取信息时,它显示为单个字段。例如:维度由以下方式设置:

axRec.setField("Dimension[1]","A");
axRec.setField("Dimension[2]","B");
axRec.setField("Dimension[3]","C");
// and so on...

我怎么知道“维度”有多少个字段?

4

1 回答 1

2

AX 支持编译时函数dimOf来返回计数,但 .Net 不提供此功能!

拯救来了DictField类:

X++ 代码:

DictField df = new DictField(tablenum(CustTable), fieldnum(CustTable, AccountNum));   
if (df)  
{ 
    print strfmt("The arraySize is %1.", df.arraySize());  
}

您可以创建一个 X++ 实用程序函数,然后调用它:

static int arraySize(str tableName, str fieldName)
{
    DictField df = new DictField(tableName2Id(tableName), fieldName2Id(tableName2Id(tableName), fieldName)));   
    return df ? df.arraySize() : -1;  
}
于 2013-02-16T08:35:34.087 回答