Friday, February 17, 2017

AX 2012 SysLookupMultiSelectCtrl issues

While working with SysLookupMultiSelectCtrl, we came across 3 issues:

Scenario: We had 3 controls in our form:

  1. Dimension name - displays all financial dimensions (Existing and custom types)
  2. Dimension Value - displays values of the dimension selected in the above control
  3. ItemId - Multiselect lookup. Shows all released products having above dimension value

Issue 1: ItemId lookup is not opening for the first time. But When i try to open it again(2nd time), it shows data. This issue occurs only when opening for the first time

Resolution: Not sure how this works. But moving below code from ItemId.lookup() to DimensionValue.modified() resolved the issueItemIdCtrl   = SysLookupMultiSelectCtrl::constructWithQueryRun(element, msCtrlItemId, ItemIdQueryRun);

Issue 2: ItemIds are displayed in the multiselect control first time. But when we change the selection in either Dimension name OR value and open the ItemId lookup, data is not refreshed (in fact, lookup method is not firing)

Resolution: Declare ItemIdQueryRun as global variable instead of local variable. After Dimension value selection is changed, get query and querybuildsource from the queryRun and clear ranges from the query. Add ranges again and call refreshQueryRun()

Issue 3:After selecting multiple ItemIds, and then try to get selected products into a container using getSelectedFieldValues() - It returns truncated ItemIds (e.g. ItemId "00050000" is returned as "50000")

Resolution: This is an issue with the getSelectedFieldValues(). getSelectedFieldValues() calls str2con(). str2con() takes an optional parameter to specify whether to convert contents into Int64 or not. It's default value is true. For some reason, multiselectlookup is not passing this parameter to getSelectedFieldValues() and hence values are always converted to Int64 while populating container. We created a new method in SysLookupMultiSelectCtrl and called str2con() with false as last parameter and it worked fine.


References: https://community.dynamics.com/ax/f/33/t/178799