This article is dedicated to Microsoft Dynamics Axapta and the C# community. Microsoft dynamics Axapta is an ERP for large scale industries. Every large organization has their own legacy system which they want to integrate with Microsoft dynamics Axapta so that without much effort they can leverage Microsoft Dynamics Axapta and their existing C# application. To understand it better, assume that the clients' C# application is having the UI with some functionality and we want to utilize that functionality in Microsoft dynamics Axapta without building that functionality from scratch but instead only passing the desire input for C# application from Microsoft Dynamics Axapta and in turn getting the output from C# application.
In order to understand the advantage of this article, please read the following scenario.
Suppose Client A is having one application B which is working perfectly fine to accomplish their small business goal. Now after some time, they decided to implement ERP Microsoft Dynamics Axapta to streamline and enhance their business process and to obtain profit. Suppose, the functionality B is not in ERP Microsoft Dynamics Axapta and client does want to implement that functionality in Axapta as already they are satisfied with that and application is having the DLL so that it can be used by other application. Hence to achieve this, we can integrate the application B of Client A to Axapta and thus by achieving this type of integration, client does not need to invest time and money in implementing the functionality to a larger extent. This article will also help any ISV partner for Microsoft Dynamics Axapta to have a POC of how to integrate the Axapta with C# application. Any ISV partner can develop their add-on and then expose their functionality as an DLL with API, which in turn Axapta will be utilized so that Axapta functionality is integrated to Add-on.
To develop a POC, I had developed a C# DLL “CvrtC2Frnt.dll” with project name as
CvrtC2Frnt. After that “CvrtC2Frnt.dll” is utilized in Axapta to integrate the Convert Temperature application with Axapta table and form.
I am providing the source code for the following items:
- Axapta code to integrate with Convert Temperature application
In addition to the above, I am also providing a sample application to test the CvrtC2Frnt.dll without using Axapta too.
There are many ways to integrate Axapta with .NET applications. In my upcoming articles, I will be covering some other aspects of integrating Axapta with .NET applications.
Step 1: Creation of “CvrtC2Frnt.dll"
Create a C# project of type Class Library with the namespace
CvrtC2Frnt. Let us assume that we have named the solution, "
First, we will create the “
CovertTemp” class. We will create the following members as follows:
public class ConvertTemp
public static double sourceTemp=0, destTemp=0;
public static bool Faren = false;
public static double ConvertCelsiusToFahrenheit(double c)
destTemp = 0;
destTemp = ((9.0 / 5.0) * c) + 32;
return ((9.0 / 5.0) * c) + 32;
public static double ConvertFahrenheitToCelsius(double f)
destTemp = 0;
destTemp = (5.0 / 9.0) * (f - 32);
return (5.0 / 9.0) * (f - 32);
The above code clearly specifies that two functions are created to convert temperature from Fahrenheit to Celsius and vice versa.
Now, we will add new windows form “
ShowTemperature”, which will contain the UI for leveraging the functionality and interface to applications like Axapta.
Add the following controls on the form:
- Text Box of name
- Text Box of name
- Label Box of name
lblsrcTemp with blank value in Text property
- Label Box of name
lbldesTemp with blank value in Text property
- One Command button with Text as
Convert and name as
Note: Text of labels will be displayed dynamically depending upon the type of conversion like if conversion is taking place from Fahrenheit to Celsius, then label
lblsrcTemp will contain the Text as Fahrenheit and “
lbldesTemp” as Celsius.
Now, create the following functions of class
public ShowTemperature(double Temperature, Boolean Fahrenheit)
txtSourceTmp.Text = Temperature.ToString();
ConvertTemp.sourceTemp = Temperature;
ConvertTemp.Faren = Fahrenheit;
private void btnConvert_Click(object sender, EventArgs e)
if (ConvertTemp.Faren == true)
txtDestTmp.Text = Convert.ToString
if (ConvertTemp.Faren == false)
txtDestTmp.Text = Convert.ToString
private void ShowTemperature_Load(object sender, EventArgs e)
if (ConvertTemp.Faren == true)
lblsrcTemp.Text = "Farenheit";
lbldesTemp.Text = "Celsius";
lblsrcTemp.Text = "Celsius";
lbldesTemp.Text = "Farenheit";
Now, create the function
ShowResult in class
ConverTemp as follows:
public void ShowResult(double Temperature, bool Farenhite)
ShowTemperature sT = new ShowTemperature(Temperature, Farenhite);
The above function in created to first call the constructor of
ShowTemperature class with Temperature and type of temperature (Fahrenheit or Celsius) values. Afterwards,
ShowTemperature UI is called to display corresponding UI.
This step is optional as already our DLL is created but to test before we actually use it in Axapta, we can perform Step E.
Add a New project of type Windows Form Application to the existing solution. Put the name of project as
ShowUI. Add a reference of
CvrtC2Frnt.dll in references.
Now design the form as given below:
The above form will work as follows:
If the value in
Temperature Text box is as 50 and Fahrenheit check box is checked out, then it means that Temperature is given in Fahrenheit. When user will click on button
Show Convert Temperature UI, then UI which was created in step B will be displayed.
Now the code behind
Show Convert Temperature UI button is as follows:
private void btnShowUI_Click(object sender, EventArgs e)
ConvertTemp ct = new ConvertTemp();
if (chkFaren.Checked == true)
Now build the application and run it to test the result.
Click on this to get the UI for converting Fahrenheit to Celsius.
Click on Convert button to convert Fahrenheit to Celsius
Step 2: Integrate the CvrtC2Frnt.dll with Axapta
To perform step 2, you need to have Microsoft Dynamics Axapta installed in your system. Assuming that this is installed and running, follow the steps given below:
- Copy CvrtC2Frnt.dll file into the Bin folder under Microsoft Dynamics Axapta installable folder. i.e. C:\Program Files\Microsoft Dynamics AX\50\Client\Bin.
- Open AOT (Application object tree). AOT is a development environment in Axapta. By using AOT, we can customize and develop new functionalities in Axapta.
Click to Open AOT or Press CTRL+D
- Now under AOT, go to References and expand it. Then click over Add Reference. Browse the CvrtC2Frnt.dll file into the Bin folder under Microsoft Dynamics Axapta installable folder. i.e. C:\Program Files\Microsoft Dynamics AX\50\Client\Bin.
Click on Browse and select file CvrtC2Frnt.dll
- Click on Open after selecting CvrtC2Frnt.dll file from into the Bin folder under Microsoft Dynamics Axapta installable folder. i.e. C:\Program Files\Microsoft Dynamics AX\50\Client\Bin.
Click on Open
- Click on Ok to add the reference.
Click on Ok to add reference.
- Now create a New Project in Axapta name as
ConverTemp. Press CTRL+SHIFT+P to open Project window and then right click on
private node of Project window. Select New-> Project to create New Project.
Click on Project to create New Project
Rename the new project as
- Create two groups and rename it to Form and Class.
Click on Group two times to create new Groups and rename it to Form and Class
- Now right click on Class node under
ConverTemp project and click on New-> Class to create new Class. Rename it to
Click on Class to create new Class in Axapta
- Now go to Class Declaration which is under and click Edit to open it.
Click on Edit to edit class declaration of ConvertTemp Class
- Write the following code in class declaration:
The above code is creating the object for
ConvertTemp class which is defined in
- Add a new method
Temperature class in Axapta. Right click on temperature class and click on OverideMethod->New to add a new method. Rename the new method as
Click on New under OverideMethod to create new Method.
- Right click on
ConvertTemperature method and select Edit to add code to it.
Click on Edit to edit the class
Add the following code to the editor:
void ConvertTemperature(real Temperature, Boolean Fahrenheit)
ct = new CvrtC2Frnt.ConvertTemp();
The above function is taking two parameters as
Fahrenheit. Both parameters are passed to the
ShowResult API defined in
- Right click
Temperature class and select
Save to save and compile the class.
Click on Save to save and compile the Temperature Class
- We will create two new fields in
SalesTable of Axapta:
Open AOT and go to data dictionary. Click on Tables and search for
Go to fields and right click over it and select new field of type real.
Rename it Temperature.
Add a new field as define of type as
Rename it to Farenhite.
Select the value in extended type property as Temp Type which is again a user
enum of type NoYes. Hence before creating Farenhite field, first create the User
To create the
TempType Enum, go to Extended Data Types in Data dictionary and right click select new->
Click ExtendedData Type -> Click Enum
Rename it to
TempType and go to property. Select
EnumType property value as NoYes.
Now save it and go to
DataDictionary. Search the Farenhite field created earlier and then go to
ExtendedData Type property and select
TempType as value.
Now save it.
- Now we will add two fields created in the above step to
SalesTable form under Form section in AOT. Select Designs->Design->
Grid:GridHeader and drop Temperature, Farenhite field from
SalesTableForm in it.
Now Save it.
- Now Drag and drop the
SalesTable Form from AOT to
Form group under
ConverTemp project in Axapta. Please note that Form group is created under point 2 of Step B.
- Now, we will create the
Convert Temperature button on
ButtonGroup:ButtonsHeader and right click to select new
CommandButton control on
Click on CommandButton to create new Command button
- Right click on new command button and click properties to open property window. Go to Text attribute and enter value as
Enter Convert Temperature -> Click on properties.
- Now we will create a new method clicked associated to
ConvertTemperature button. This method we will create by right clicking on Methods under
ConvertTemperature button and then selecting
Overide method and then selecting Clicked.
Select Clicked to override click method
- In the editor window, copy the following code:
Temperature tem = new Temperature();
The above code is creating the object of class
Temperature created in Axapta. Then we are calling
ConvertTemperature function defined in
Temperature class of Axapta with parameters as Temperature and Farenhite from
SalesTable in Axapta. Earlier in point 1 of Step C, we had created two new fields in
SalesTable of Axapta, i.e.:
- Temperature (Data type: real)
- Farenhite (Data Type: Enum with boolean)
- Save the Code and run the SalesTable Form. To run go to Account Receivable module of Axapta and then click Sales Order.
Click on Account receivable
Double click on Sales Orders under Account Receivable module of Axapta. Under Sales Order Grid, select any record and double click and go overview tab of Sales Order form. Scroll to find out the Temperature and Farenheit field.
First click on Sales Order
Enter Temperature as 59 and check the Farenhite Check. (If Farenhite is checked, then the temperature in Temperature field is in Fahrenheit and upon clicking Convert Temperature, command button will convert it to Celsius. If the Farenhite checkbox is not checked, then the temperature in Temperature field is in Celsius and upon clicking Convert Temperature command button will convert it to Fahrenheit).