I found some workarounds to calling kernel functions:
tableName2Id
(I was originally thinking of the tablenum
method):
//I used an extension method here
public static int GetTableId(this Axapta ax, string tableName)
{
return (int)ax.CallStaticClassMethod("Global", "tableName2Id", tableName);
}
curUserId
//Another extension method
public static string CurUserId(this Axapta ax)
{
return (ax.CallStaticClassMethod("xUserInfo", "find") as AxaptaRecord).get_Field("Id").ToString();
}
fieldName2Id
(I was originally thinking of the fieldnum
method)
//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;
}
I hope this helps someone else!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…