In Dynamics AX, using the Business Connector, what do you call kernel functions?

I would like to know how to call kernel functions from AX using C # (.Net Business Connector).

In particular, can you call methods like fieldName2Id, tableName2Id, and curUserId?

+3
source share
1 answer

I found some workarounds for calling kernel functions:

tableName2Id

(I originally thought about the method 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

(I originally thought about the method 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;  
    }  

I hope this helps someone else!

+9
source

Source: https://habr.com/ru/post/1746075/


All Articles