How to Use AX Form As lookup in Dynamics Ax 2012

by alirazazaidi on August 27, 2014

Consider a scenario where, I required a StringEditControl and Clicking on Control a lookup is open where the list of Customer of selected Legal Entity are available. And After Selecting required Customer, Customer Id Or AccountNum is return form Lookup form.


For This purpose we have to create form, which will used as look Up.

Create a New form. Name It  “FormCustomerLookUp”

New Form

In Data Source Create and New dataSource Name It CustomerTable and Point to CustTable.


Customer Table As DataSource

Expand the Design node  and Right Click on It and Add Grid, Now from CustomerTable Data Source, Drag and drop “AccountNum” and “Party” on Grid. It will create two String Edit Control on Grid bound with CustomerTable.



Now Select on “StringEdit:CustomerTable_AccountNum” select Properties. Form Properties window Set Its Auto declaration  property to True.



Now expend the Methods Node form and Right click and override the Init method from there and add following line of code there.







Now right click on Design Node and Update following properties.







Now Create a form where this lookup will use. For this Article I have to create very simple form with only on stringEdit textbox.

On its Design Right click and create StringEditButton with Name “LookUpTest” and from Its property window Auto Declare Property is set to Yes and lookupButton property to “Always”.













Now Add two method, One used to Register control with Lookup, and Second method will use to call lookup form and gets its value.

protected void configureCustomerLookUp(FormStringControl stringControl)


if (stringControl)






methodStr(FormStringControl, lookup),

identifierStr(CustomerLookUp), this);








Second method will be called on lookup button click



private void CustomerLookUp(FormStringControl stringControl)


Args args = new Args(identifierStr(FormCustomerLookUp));

FormRun lookupFormRun;





lookupFormRun = ClassFactory::formRunClassOnClient(args);









If you have already some knowledge above code is easily Understanable, where  Ax form Name set in args and instance of from is created at runtime and then attached the form to string controls performLookUp method.




Now run the form. And click on lookup button on textbox.



Click on LookUp Button




Selected Value will show on text box when you click on lookup grid






Nice Experiments, Now you can use This functionality as you want,





Import Export Model with Dynamics Ax 2012 R3

by alirazazaidi on August 21, 2014

As per my understanding for commands, Examples are more easily understand and quick solution instead of syntax.


For model store export/import we have to use Dynamics Ax Management Shell. You can find “Dynamics Ax Management Shell” at  All Programs, Administrative Tools and Microsoft Dynamics Ax Management Shell.

Dynamics Ax Management Shell




Export Command Syntax  (Windows PowerShell) :

Export-AXModel –Model <name> -File <Filename.axmodel>

Example : abcd is name of Model, file name can be different model store name.

Export-AXModel -model  abcd -file c:\abcd.axmodel


Import Command Syntax (Windows PowerShell)



Install-AXModel -File <Filename.axmodel> -Details


Exmaple :

Install-AXModel -File C:\abcd.axmodel –Details


In the case of some files exist in another model then add “-Conflict Push”


The complete command is here


Install-AXModel -File C:\abcd.axmodel -Details -Conflict Push


How to clear inactive sessions from Dynamics Ax 2012

by alirazazaidi on August 19, 2014

If you check the online user in Administrator Module, You may be found some session with inactive and block status. These inactive and block session are due to crashing of AX clients. These sessions are not create any problem, but possible issues with limited number of active users under Dynamics Ax license. Best approach to clear these inactive and block session form Dynamics Ax to avoid any future conflict with Licensing. All these session information is stored in “SysClientSessions.” Table.

Second Problem we usually face that when we start AOS service, it take too much time change status from Starting to started. One of many reason for this phenomena that AX try to query and located any Active session in SysClientSessions.  To reduce the time is to remove all session inactive from SysClientSessions table or possible remove the inactive and block session form Database. In “SysClientSessions” Status with status 0 (Inactive), Status 2 (Ending Waiting for AOS), 3 (Ending –Block).


Perform following steps.

  1. Stop AOS service.
  2. Open SQL Server Management Studio
  3. Open any new query on Dynamics Ax Database.
  4. Run the following Query where sessions with status 0 (Inactive), Status 2 (Ending Waiting for AOS), 3 (Ending –Block).

delete from SysClientSessions where status in(0,2,3)

  1. Restart AOS.

Hopes this will works to start AOS service faster than previously.


Dynamics Ax 2012 R3 System Requirements

by alirazazaidi on August 15, 2014

System Requirements for Microsoft Dynamics Ax 2012 R3 Updated by Microsoft. For this purpose Microsoft uploaded a new document , you can download it from this link


How to get Standard SQL out from Query Object in AOT?

by alirazazaidi on August 15, 2014

We can get standard sql from AOT Query object through X++ code.

Following X++ Code used to get Standard Sql out of EcoResProductListPage



static void Job2(Args _args)


Query query;

query = new Query(queryStr(EcoResProductListPage));






Updated version for “Inside Microsoft Dynamics Ax 2012” is now out. It is updated for AX 2012 R3 version.

What’s new :Inside Microsoft Dynamics AX 2012 R3

  • It include a new chapter about developing companion apps.
  • It include a new chapter about application life cycle.
  • A new sections about LINQ support and print management.


You can purchase inline from:





Clear the Cache on all clients Dynamics Ax 2012

by alirazazaidi on August 10, 2014

Last week I post a solution to problem of old code on Dynamics Ax 2012 Client, That work for single client and it is not possible to clear cache on manually on every client. Later I found better solution to reset the client cache at AOS. Reference is

According to that reference we have to reset the GUID, so all Clients have to reset its cache, this method required AOS restart.

static void ResetAUC(Args _args)
SysSQMSettings _Settings;
update_recordset _Settings setting GlobalGUID = str2Guid(#EmptyGuidString);
info("Now we have to Restart the AOS Service to use a new GlobalGUID.");

Its works for me.


Little bit taste of List In Dynamics Ax 2012

by alirazazaidi on August 5, 2014

In Dynamics Ax List is used as collection, You can add , remove or update elements in it. Type of list is define at the time of its declaration and cannot be change after initialization.

We can iterate in List with the help of ListIterator object, which have several methods to process on list.

 List           intList       = new List(Types::Integer);
    List           strList = new List(Types::String);
    ListIterator   literator  

    // add the element at the end of the list

    // add the element at the start of the list


    strList.addEnd ("Raza");

    strList.addStart ("Ali"); 

    strList.addStart ("Zaidi"); 

    // If you want to insert the data at some specific index, then you need to make use of the listIterator class 

    // Iterator performs a midpoint 

    // insert at current position. 

    literator = new ListIterator(strList);
    while (literator.more())
        // can provide some condition, i.e. if check etc
        if (literator.value() == "Ali")
            listIterator.insert ("Between Raza and Zaidi");


My friend Bashir Ahmad Malik got following error during start up dynamics Ax service.


“The Microsoft Dynamics AX Object Server 6.2$01-MicrosoftDynamicsAX service terminated with service-specific error Code 90.
Suspect state of SQL Server database is a state when you are unable to connect to the database. “


During trouble shooting we find following root causes.


  • database is corrupted
  • database files are being “opened” or held by some process (operating system, other program(s)…)
  • not enough disk space for SQL Server
  • insufficient memory (RAM) for SQL Server
  • unexpected SQL Server shutdown caused by power failure


we solve this problem by following Sql Script.

  1. Connect database server with Microsoft SQL Server Management Studio.
  2. Execute the following SQL script in given order:

NOTE: replace [DatabaseName] with your database name

-- This query will rollback any transaction which is running on that database

-- and bring SQL Server database in a "single user" mode



-- Marking database READ_ONLY, disable logging,

-- and limiting access only to members of the sysadmin fixed server role



-- Checks the logical and physical integrity of all the objects in the specified database

DBCC checkdb(MicrosoftDynamicsAX)


-- In case of simple failure then we can use allow data loss option to recover Database


--  DBCC CheckDB (MicrosoftDynamicsAX, REPAIR_ALLOW_DATA_LOSS)


-- Set database accessibility to it's original state, allowing all logins


EXEC sp_resetstatus MicrosoftDynamicsAX

reference :


Dynamics Ax 2012 Client cache problem

by alirazazaidi on August 3, 2014

A few days ago, I was working on Dynamics Ax 2012 customization. When I shifted code to QA server, Compile, Generate CIL, but no changes display on client. I was shocked, latest code working fine on my machine but why it is not working on QA server. AOT shows the latest code. During troubleshooting I found that it is due to Client Cache.  For this I have to delete cache files form cache folder. AX cache files have “auc” extension.


I found auc files from following folder



I perform following steps.

  1. Close Client on machine.
  2. Stop AOS service.
  3. Delete all auc files from local cache folder.
  4. Restart AOS.
  5. Open client.


I found latest code working fine on QA server.