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.

 

CustomerFields

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

 

LookUpFieldAutoProperties

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

 

    element.selectMode(CustomerTable_AccountNum);

 

LookUpFormInitialization

 

 

Now right click on Design Node and Update following properties.

Width=360

Style=LookUP.

StyleToLookUp

 

 

 

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”.

 

TargetFieldProperties

 

LookUpFields

 

 

 

 

 

 

 

 

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)

{

 

 

stringControl.visible(true);

stringControl.registerOverrideMethod(

methodStr(FormStringControl, lookup),

identifierStr(CustomerLookUp), this);

 

}

}

LookupRegisteration

 

 

 

Second method will be called on lookup button click

 

 

private void CustomerLookUp(FormStringControl stringControl)

{

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

FormRun lookupFormRun;

 

args.parm(“”);

args.caller(this);

 

lookupFormRun = ClassFactory::formRunClassOnClient(args);

lookupFormRun.init();

 

stringControl.performFormLookup(lookupFormRun);

lookupFormRun.wait();

 

 

}

LookUpMethods

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.

TargetButtonForm

 

Click on LookUp Button

 

 

LookUpClick

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

 

SelectedValueInTarget

 

 

 

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

 

 

 

{ 0 comments }

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

{ 0 comments }

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.

{ 0 comments }

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

http://www.microsoft.com/en-pk/download/details.aspx?id=11094

{ 0 comments }

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

 

EcoResProductListPage

static void Job2(Args _args)

{

Query query;

query = new Query(queryStr(EcoResProductListPage));

info(query.dataSourceNo(1).toString());

}

QueryInfo

 

{ 0 comments }

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:

 

 

 

{ 0 comments }

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

http://thwidmer.wordpress.com/2010/05/19/reset-program-cache-file-for-all-clients/

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)
{
#AiF
SysSQMSettings _Settings;
;
ttsbegin;
update_recordset _Settings setting GlobalGUID = str2Guid(#EmptyGuidString);
ttscommit;
info("Now we have to Restart the AOS Service to use a new GlobalGUID.");
}

Its works for me.

{ 0 comments }

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
    intList.addEnd(123); 

    // add the element at the start of the list
    intList.addStart(321); 

    intList.addEnd(300); 

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

{ 0 comments }

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

ALTERDATABASEMicrosoftDynamicsAX SETSINGLE_USER WITHROLLBACKIMMEDIATE

 

-- Marking database READ_ONLY, disable logging,

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

ALTERDATABASEMicrosoftDynamicsAX SETEMERGENCY

 

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

ALTERDATABASE MicrosoftDynamicsAX SETMULTI_USER

EXEC sp_resetstatus MicrosoftDynamicsAX


reference : http://social.technet.microsoft.com/wiki/contents/articles/25820.repair-a-suspect-database-in-sql-server.aspx

{ 0 comments }

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

C:\Users\aliraza.zaidi\AppData\Local\

 

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.

{ 0 comments }