Tuesday, March 8, 2011

Languages in AX 2009 - Using a the LanguageTable form for Lookup building- AX 2009

Today I had a requirement to only show the following language across the whole application:
  • en-us
  • fr
  • it
At first I thought to create a custom lookup method as I did for another requirement last month (http://axwonders.blogspot.com/2011/03/filter-activity-form-contact-to-only.html), but then I thought .. Oh my .. this would mean to add a lookup method to several forms across the application, and what about if I need to change something in the future? It was a fact that the scalability of this change will be an issue.

Because the requirement said "Across the application" I decided to modify the LanguageTable form to be shown as a lookup in every instance of the LanguageID across the application.

The following are the steps I took:


languageGrid_LanguageId: This is the name of the control in the LanguageTable form, which is within the grid.

Languages_ds: This is the LanguageTable form's data source name

1- Override the LanguageTable form init() method with the following:

public void init()

2- Override the LanguageTable form run() method:

public void run()
    FormStringControl   callingControl;
    boolean             filter;
    callingControl = SysTableLookup::getCallerStringControl(element.args());
    filter = SysTableLookup::filterLookupPreRun(callingControl, languageGrid_LanguageId, Languages_ds);
    SysTableLookup::filterLookupPostRun(filter, callingControl.text(), languageGrid_LanguageId, Languages_ds);

3- Override the LanguageTable form data source (in my case is called Languages) init() method

public void init()
    Query                   query;
    QueryBuildDataSource    qbds;
    QueryBuildRange         qbr_US;
    QueryBuildRange         qbr_IT;
    QueryBuildRange         qbr_FR;
    SysTableLookup          lookup;
    LanguageId              languageId  = 'en-us';
    LanguageId              languageId2 = 'it';
    LanguageId              languageId3 = 'fr';
    query = new Query();
    qbds = query.addDataSource(tablenum(LanguageTable));

    qbr_US = qbds.addRange(fieldnum(LanguageTable, LanguageId));
    qbr_IT = qbds.addRange(fieldnum(LanguageTable, LanguageId));
    qbr_FR = qbds.addRange(fieldnum(LanguageTable, LanguageId));



4- Go to AOT > Data Dictionary> Extended DataTypes and look for the LanguageID extended data type and modify the property called FormHelp by adding the form LanguageTable. Save the changes.

The final result looks like this:


  1. This is a nice article..
    Its very easy to understand ..
    And this article is using to learn something about it..

    c#, dot.net, php tutorial

    Thanks a lot..!

  2. Thank you so much Muhammad. It is great that you liked it. Do you also work with AX 2009?

  3. Thanks a lot. Very clear and helpful


Thank you for your thoughts. Your comment will appear in my blog shortly after review.

Have a great day!