|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
Axapta ax; Object axObject; try { // Create a new Axapta object. ax = new Axapta(); // Logon using the default settings // in the AX configuration for the .NET // Business Connector ax.Logon(null, null, null, null); // Call the static method and return the // result to the axObject variable axObject = ax.CallStaticClassMethod("Global", "AxHelloWorld"); // Print the result to the console Console.WriteLine("The message from AX is {0}", axObject.ToString()); ax.Logoff(); } catch (Exception e) { Console.WriteLine(e.Message); } |
Another good example for finding a record ID by calling the standing find method from a table
|
1 |
ax.CallStaticClassMethod("xUserInfo", "find") as AxaptaRecord).get_Field("Id").ToString() |
And another…
|
1 2 3 4 5 6 7 8 9 10 11 12 |
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; } |