Now we start development of form. First form we will build for Simple list form for Diagnostic table

For this open AOT and right click on Form Node and click on simple list form template



Drag newly created form in Project and rename it “DiagonasisticTable”.


Expand DiagonsisticTable form and Right click on data source node to new Data source. Update name of name and Table name as DiagonsisticTable.


Now expand Designs=> Design Expand=> group Container and select grid



Right click on grid, click on properties window and set these properties

Data Source: DiagonasisticTable

DataGroup: overView



Save the form and right click on form open it. The form will look like similar

NewDiagonaistic Form


If you try to enter duplicate values in Diagnostic number field. Due to unique index on Diagnostic number it did not let you do it.






New create a display menu with Name “MnuDiagonisticTable” and set it object Type to form and object Name as “DiagonisticTable”.  Save it.



Now expand Diagonaistictable right click on it and set its “FormRef” property with mnuDiagonisticsTable


This property provides us option of “View Details” on lookup field. We see its function in Master detail form.


Detail form:


Now we create a detail from for patient table. Create a new form and add data source and set its Name and DataSource value to Patienttable.


Right click on PatientTable data source and set “InsertIfEmpty” to false



Now expand Designs and add new action tab, inside button group add three command buttons.

Rename them into “btnNew”, “btnEdit” and “btnDelete”. And from property window set their command to new, edit and delete.



You can also select button Image by update following Properties


New Img property

Now expand Designs=>Design under ActionTab add a new Tab. Set Tab style property to fast tab.

Add new tab page in Tab and set is width and height value as follow





Add new group control set its width and height like above one and column property to 2.

And set is data source to patientTable and Data group property to overview


Now form structure will look like


Now open the form let’s see how it look like


Test the form and click add remove entries



Parent child form:


Now we expand patientTable form to Parent child form.

Now expand DataSource of node of PatientTable form and add a new data source. And set its table property to AdmissionTable, Name to AdmissionTable, and Set its JoinSource to PatientTable








Now expand the form designer and add a new tab Page under patient tab and add new action pane There Set DataSource Property of ActionTab to AdmissionTable so all control inside this action tab works for AdmissionTable. In Button group add three command buttons and set their name “BtnNewAdmission”, “BtnEditAdmission” and “BtnDeleteAdmission”. After this set  there command property  to “New”,”Edit” and “Delete”.


Now add a grid in this tab and set its data Source to AdmissionTable.




Drag and drop fields from AdmissionTable data Source to grid



Now open the form lets how it look like

Our parent Child from

You can see that here admission Date is greater than Discharge Date, for this we have to add some validation rules, which are not part of current post. We let it go.


If you right click on diagnostic number field in grid, from pop up menu view detail option leads us Diagnostic table form.

ViewDetail link


This option comes due to we add menu Item in table properties in one of above step I am again adding its picture here



Now we create a new Display Menu Item “MenuPatientTable” and set its object property to



Now we create a List page for Patient and attached Patient detail form with it.


For list page template we cannot attach table in data source for this we can create a Static Query Object. This Query Object will use as data Source in Form


First we have to create a Query. Re Name it to PatientQuery and form its DataSource add Patient table



Expand PatientTable source in data table and right click on fields and set its field property to yes



After saving you will find all fields in Query




Now open AOT and right click on Form Node. From pop up menu select form template and then select list page.



Now search form with similar CopyOfSysBPStyle_ListPage Name.  Drag it to your project and rename it to PatientListPage


Now expand Patient List page and set data source and sets property to PatientQuery. This query we created in previous step



This will result in all tables in query in forms data source. By default these table have create and edit to no.


Expand Designer  node of Form and select grid and set its dataSource property to Patient and drag and drop required fields from PatientTable_1 data Source to form.


Patient list Page grid


Now drag and drop required fields from data source to grid





Now we are going to attached PatientDetail form with Patient

Now we add the Add, edit, delete and view functionality which leads the PatientDetail form

Expand the action tab in form and right click on menuItemButton  “newbutton”


Set following properties




Expand next button group “MaintainedGroup” and and Open property window of EditButton



From Property window set following fields

DataSource = “PatientTable_1”

OpenMode =”Edit”


MenuItemName =”mnupatientTable”



Now select mnuItemButton “ViewButton”



From Property window and set

DataSource = “PatientTable_1”

OpenMode =”View”


MenuItemName =”mnupatientTable”








Now expand grid in form and set following property to MenuItemButton “ViewButton”, which we set in above step, so when we click on grid, detail form opens




Now run the form and lets try all functions.


Now create a new Display menu Item Say “MnuPatientListPage”. Set its form Property as follow

Menufor ListPage


Suppose That is hospital registration development is part of Accounts Payable module.


Expand the menu Accounts Payable module expand common.

Add a new menu Item or drag drop existing menu item Common Set its following properties

Menufor ListPage


Now Open Ax client and open Account Payable area page






Consider a scenario where we are going to build small Hospital Admission System in Dynamics Ax 2012.  This Add-on is based on small database design based on





We divide this task into two posts

For this post, we are cover following points to develop this small add-on

  • Ax Project
  • Patient, Diagnostic and admission table.
  • Simple list page for diagnostic table.
  • Entry form for Patient table (Detail form).
  • Parent Master detail form based on Patient ,Diagnostic table and patient.
  • List page for Patient table.
  • Integrate Patient List page with Patient Detail form.




AX Project:


AX Project for collecting Ax artifacts in single location.

When we create any Ax object they have to create under certain node. For example tables, forms, Classes, menu all stored in their respected node.

In Dynamics Ax we can create a Project which is not more the logical grouping of all Ax artifacts.

In these project, we create object groups and then placed our required object either drag and drop from AOT or create them here.

Advantages of Projects are

  • Logical grouping, it’s easier to locate required artifacts one location.
  • When we export project as Xpo, All objects are exported as single XPO.
  • We can export whole project into model, all object in project moved from one model to other model in single steps.



Lets make a new project


From top menu Click on View=> tools=> Project

Ax Project

Following Screen will open

Shared and Private Project

Right click on Shared folder and create a Project and renamed it to HospitalManagementSystem.


Hospital Management System Menu


New Project Managment


Click on Project and open it. Right click on it new => Group to create new groups



For example we create Form group and set it Name and Project Group type to forms

Project name


Now Project is look like

Project Details


Similarly create other groups.




Table structure design.




So our table structure look like

Diagnostic table

Column Extended data Type Primitive Data Type
DiagNo DiagnosticNumber Str10
Desc Description
Cost AmountCur Real



Patient table

Column Extended Data Type
PatNo PatientNumber Str 20
Fname Name
LName Name
BirthDate BirthDate
Address T_Address Str 20
City T_City Str20
State T_State Str20
Zip T_Zip Str20
Gender T_Gender





Column Extended Data Type Primitive Data Type Foreign Key
AdmitNo AdmissionNumber Str20
PatNO Patient Number Patient table
Diag_code Diagnosticnumber


Diagnostic table


Adminationdate FromDate date
DischargeDate ToDate date
CoPay Notes Notes


First we create a extended data type required in three tables.

First one is DiagonisticNumber extended Data Type

Extended Data Type

Rename it and set its name as “DiagnosticNumber” and its string set its size to 10


Similarly create all extended data type

List of Extended Data Type

Rest of we use out of the box extended Data Type

When you save any Extended Data Type, Ax ask for Synchronize database cancel it when all extended data Types created let it complete

DataBase Schyrni






In current example only gender is enum type, we create new base enum T_Gender instead of using out of box Gender enum.


Base enum menu

Create a new Enum and name it “T_Gender” t stands for training.


Right click on it and create a new element

Base Enum new Element



Set its name and label



Base Create one more element and it will look like

Base enum look like



Now create a click on tables group and right click and create a new table



Rename it to “DiagnosticTable”.



Now create a new field with Name “DiagNo” of string type and set its extended data type to “DiagnosticNumber”





Similarly create all other fields in table



Now expand field Groups node in Table and Create a new Field group with Name “OverView”.


Drag all fields in it.



Now want to make the Diagonistic and unique and make it primary key. For this right click and create unique index on it


Rename it to DiagNoIx and set its AllowDuplicate Property to No and Alternate key to Yes


Now drag DiagNo from fields node to DiagosticIdx.




Now right click on DiagnosticTable and set following Properties with newly created Index




Perform same steps to create PaitentTable, create Index on “PatNo” similar way.



Create a new field group with overview and arrange field in a way that you want to see them in form



Create unique index on PatientNumber


Similarly create AdmissionTable,




Now right click on Relation node in AdmissionTable and create a new relation and rename it to “PatientRelation” and sets its table property to “PatientTable”


Now Right click on relation click on new =>ForeignKey=>Single field AlternateKey based




A new field added against  relation, rename it to PatientNumber



Similarly create another key based DiagnosticTable




Save and compile all table and synchronize each table.


Form development will be on next post


Today I got very this error on deployment of customized SSRS report. The customization code was written in Dynamics AX 2012 R2 and it was successfully migrated to Dynamics Ax 2012 R3


System.Web.Services.Protocols.SoapException: Error while loading code module: ‘Microsoft.Dynamics.Framework.Metadata.AX, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35’. Details: Could not load file or assembly ‘Microsoft.Dynamics.Framework.Metadata.AX, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35′ or one of its dependencies. The system cannot find the file specified.

at Microsoft.ReportingServices.Library.ReportingService2005Impl.CreateReport(String Report, String Parent, Boolean Overwrite, Byte[] Definition, Property[] Properties, Guid batchId, Warning[]& Warnings)

at Microsoft.ReportingServices.WebServer.ReportingService2005.CreateReport(String Report, String Parent, Boolean Overwrite, Byte[] Definition, Property[] Properties, Warning[]& Warnings)



Solution is open the report In Visual studio, compile it, deployed it and add to AOT.


List of user under certain Role Dynamics Ax 2012

by alirazazaidi on May 26, 2015

Consider a real time scenario, where we have to send alerts to all user in certain Role In Dynamics.

For this purpose we have to loop through all user in certain role.

User, roles and role assignment are done three tables, these tables are hidden in AOT.


These table are

UserInfo : This table holds all User Ids In Dynamics Ax 2012.

SecurityRole : This table hold all Security Roles, In this table has two important fields “Name” which is descriptive and second one is AOTName. If you get the current customer assigned role using then this AOTName will be return.

SecurityUserRole: This table holds many to many relation with security and User.


For below snippet, I loop through all user assigned in Sales Representative.


   static void RoleUSerID(Args _args)


UserInfo    userInfo;

SecurityUserRole securityUserRole;

SecurityRole       Roles;


while select userInfo

join securityUserRole

where securityUserRole.User == userInfo.Id

join Roles where Roles.RecId  == securityUserRole.SecurityRole

&& Roles.AotName ==”TradeSalesRepresentative”







There are several reasons for internal server Error 500,  But today i was facing this error in local deployment of enterprise portal. Previously enterpise portal works perfectly fine. I solve it in two steps

  1. Restart the IIS.
  2. Regenerate the WCF configuration By clicking on refresh button  from Dynamics Ax Server configuration. Following screenshot will help you.



Hopes this helps.



Today I got change to work with timeedit control in Ax where we have to get input of time and then take difference to get number of hours.

For this example I used timeEdit control and add two timeEdit control in form.These timeEdit controls are unbound, I set the out of the box FromTime and ToTime extended data Type and set auto declaration property to true so these controls can be access by name in code.


Similarly set the properties ToTime.


Now add button and add its click method. The time difference between two times value can be get with timeConsumed out of the box function.


void clicked()







5-15-2015 12-19-11 AM

output is as

5-15-2015 12-19-25 AM





out put is as


5-15-2015 12-19-51 AM


Today  I was debugging the logic written for Custom AIF services  using X++ job before deploy it as AIF service, I got strange error


Stack trace: ‘unchecked’ cannot be called on the client.”. 


5-6-2015 2-30-14 PM


It was due that Service class was set as run  at “Called from”, Only solution is to change run at to Server. Job will successfully run.

5-6-2015 2-30-53 PM


Dev and test Retail essential is single VM based environment, On which everything need for Retail customization is available.  Yesterday I successfully configured for me. following are some step by step notes for its deployment and configuration.


Login in on following link to login in you Lifecycle services for Dynamics. For this you must have partner source or customer source credentials



After successful login create a new Project.




For Example I created a new project “Azure On Ax” with following configuration

Create Ax

New Project

Now go on at new Azure based environment a click on this. Here add Guid for you Azure subscription.

New Azure deployment

Click on next button.

4-28-2015 11-42-36 PM

Click on download button to download the certificate and now login in your azure from Azure management portal.

4-28-2015 11-44-33 PM

From setting menu, upload the certificate.





Now go back to Life cycle services page and click on next button.

4-28-2015 11-42-36 PM

Select location.

4-28-2015 11-49-07 PM

Click on Test / dev environment because we want test and dev environment.


4-28-2015 11-49-28 PM

From Advanced menu you can change environment form Dynamics Ax 2012 R3 CU8 to Dynamics AX 2012 R3. By default it will configure the Dynamics Ax 2012 R3.




Wait it to deployment complete.



When Vm deployed, in Life cycle services you will find user name and password.


I am more Interested in work with axlocalAdmin user so I want to make axlocalAdmin as system administrator ,  You can skip the following step.

If you saw in above picture you find that DynamicsInstallUser is built in user is used to configure the AX.


Login with SQL server user in VM and set axlocalAdmin as System Administrator In AX.

Run the PowerShell and run the following command.


So create user as log in with following command


$AdObj = New-Object System.Security.Principal.NTAccount(“axlocaladmin”)


$strSID = $AdObj.Translate([System.Security.Principal.SecurityIdentifier])



This command return the SID id of axlocalAdmin.


Copy the sid id update the following command and open the Dynamics Ax database in SQL server and run the update sql command.


update userinfo set

networkdomain = ‘contoso’,


networkalias = ‘dynamicAdmin’,


name = ‘axlocaladmin’


SID = ‘S-1-5-21-602381161-1523875512-907902364-500′


where ID = ‘Admin’








Now back login in with axlocaladmin

And first step to compile the Dynamics Ax with AX build command. For this


Open cmd run as administrator

axbuild.exe xppcompileall /s=01 /altbin=”C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin” /log:”C:\Temp”

axbuild.exe found at following location


C:\Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin





When above step is successfully completed.

Open AX and complete the Initialization check list.

4-29-2015 10-29-14 AM


When Initialization check list is complete, Again log in with SQL server User and inject the demo data.



On Ax environment testTransfterTool found following location.



Demo data files path is as



Stop the AOS services and run the following command.


“dp.exe import D:\DemoData MicrosoftDynamicsAx”



When data import completed. Login back axloginAdmin


And start configuring retail features.


Now go to retail sessional area page. If Retail essential area page enabled it. From File => Module=> Retail essentials.


Retail Parameters

Retail essentials => channels => retail parameters



Retail parameter


From top menu click on Initialize

4-29-2015 10-55-41 PM




wait until info log show up

4-22-2015 1-03-28 AM


Retail subject


Retail Scheduler parameters:


No click on Data synchronization => setup =>Retail Scheduler parameters

4-29-2015 11-28-12 PM


In the next open screen, set following things

  • Server Name
  • Sync meta data button at the top of the form

Enter Sync metadata button and  click on yes to confirm it








Real time services profiles setup:

4-30-2015 12-44-44 AM



Set server name and common name and close the form.



Working folder:


You can set download and upload folder. But as per documentation they are as follow.

And set download and upload folder as per following By default these are something like









Now go to setup the Channel database

Retail database



As per MSDN select Houston and click on Full data Sync and select 9999 and click ok on it.


database 9999



Reference :


Today I was configuring POS on Azure test/dev environment, I got very strange errors during compilation  of classes node.

All these classes were belong to Payroll modules.

5-2-2015 3-50-44 AM

Error described that Symmetry variable is not declare.

5-2-2015 3-50-28 AM


Later I discover that reference of ste-net.dll is missing in AOT.

This mysterious dll (mysterious for me) is found at  C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin


Yu can add  its reference by right click on reference node In AOT

5-2-2015 3-59-36 AM


5-2-2015 3-59-58 AM

Click on browse and go to  C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin


5-2-2015 4-08-59 AM

Select and click on ok

5-2-2015 4-10-42 AM

As reference is added into AOT. Compilation errors are gone.





Reading CSV files in Dynamics Ax 2012.

by alirazazaidi on April 28, 2015

Today I come across a scenario where, I have to read data from csv file.


Reading data from csv file is very easy with IO operation. For example I have csv file with following student first name and last name which I have to migrate into custom ax table.

CVS file



Custom Ax table.




Following a simple code snippet which read csv file and insert data into custom data

static void Job9(Args _args)



IO  iO;

Name FirstName;

Name LastName;

StudentInfo _StudentInfo;

FilenameOpen        filename = “c:\\StudentInfo.csv”;//To assign file name

Container           record;

boolean first = true;


    iO = new CommaTextIo(filename,#IO_Read);

if (! iO || iO.status() != IO_Status::Ok)


throw error(“@SYS19358″);


while (iO.status() == IO_Status::Ok)


record =;// To read file

if (record)


if (first)  //To skip header


first = false;





FirstName = conpeek(record, 1);//To peek record

LastName = conpeek(record, 2);


_StudentInfo.LastName =LastName;


//     info(strfmt(‘%1–%2′,custAccount,custname));







After running the ax job, I found following data into Ax table.

4-28-2015 9-59-45 PM


If you saw, first row of csv is missing in table. The reason for that above code snippet consider first row as header so it did not require to insert it.


One thing I missed, The reference, original code snippet is belongs to “Jitendra Kumar Singh”