在Dynamics AX中,使用业务连接器,如何调用内核函数? [英] In Dynamics AX, using the Business Connector, how do you call kernel functions?

查看:63
本文介绍了在Dynamics AX中,使用业务连接器,如何调用内核函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

Specifically, can you call methods like fieldName2Id, tableName2Id and curUserId?

推荐答案

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

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

(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);  
   }



    //Another extension method  
    public static string CurUserId(this Axapta ax)  
    {  
        return (ax.CallStaticClassMethod("xUserInfo", "find") as AxaptaRecord).get_Field("Id").ToString();  
    }  


(我最初想到的是fieldnum方法)

(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!

这篇关于在Dynamics AX中,使用业务连接器,如何调用内核函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆