在Dynamics AX中,使用Business Connector,如何调用内核函数?

时间:2010-05-18 21:23:04

标签: dynamics-ax-2009 axapta business-connector

我想知道如何使用C#(.Net Business Connector)从AX调用内核函数。

具体来说,您可以调用fieldName2Id,tableName2Id和curUserId等方法吗?

2 个答案:

答案 0 :(得分:10)

我找到了一些调用内核函数的解决方法:

tableName2Id

(我最初想的是tablenum方法):


   //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

(我最初想的是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(...);