- en-us
- fr
- it
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:
NOTE:
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()
{
    super();
    element.selectMode(languageGrid_LanguageId);
}
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);
super();
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';
    ;
    super();
    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));
    qbr_US.value(queryvalue(languageId));
    qbr_IT.value(queryvalue(languageId2));
    qbr_FR.value(queryvalue(languageId3));
    this.query(query);
}
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:
 

Thank you so much Muhammad. It is great that you liked it. Do you also work with AX 2009?
ReplyDeleteThanks a lot. Very clear and helpful
ReplyDelete