我想知道如何使用C#(.Net Business Connector)从AX调用内核函数。
具体来说,您可以调用fieldName2Id,tableName2Id和curUserId等方法吗?
答案 0 :(得分:10)
我找到了一些调用内核函数的解决方法:
(我最初想的是tablenum
方法):
//I used an extension method here
public static int GetTableId(this Axapta ax, string tableName)
{
return (int)ax.CallStaticClassMethod("Global", "tableName2Id", tableName);
}
//Another extension method
public static string CurUserId(this Axapta ax)
{
return (ax.CallStaticClassMethod("xUserInfo", "find") as AxaptaRecord).get_Field("Id").ToString();
}
(我最初想的是fieldnum
方法)
//Another extension method
public static int GetFieldId(this Axapta ax, string tableName, string fieldName)
{
AxaptaObject dictionary = ax.CreateAxaptaObject("Dictionary");
int fieldId = 0;
if (ax.TableExists(tableName))
{
int tableId = ax.GetTableId(tableName);
AxaptaObject dictTable = (AxaptaObject)dictionary.Call("tableObject", tableId);
fieldId = (int)dictTable.Call("fieldName2Id", fieldName);
}
return fieldId;
}
我希望这有助于其他人!
答案 1 :(得分:0)
最好使用:
Dictionary dictionary = new Dictionary();
;
dictionary.tableName2Id(...);