Search code examples
axaptalookupmicrosoft-dynamicsax

Need to get a lookup from a table field which is having duplicate values.(I need only distinct values in lookup)


Hi I have a form where i need to get a lookup from a table field which is having duplicate values. I need to get only the distinct values in the loookup. How can i acheive it?

Example.

RmTable
field1 field2 field3
t1      jyo     abc
t2      jyo     cdd
t3      jyo     ccc
t4      Kim     dd
t5      pete    ss
t6      kim     sssw

I have a form which is having a field. I need to get lookup of distinct values from field2. Can you please help me. Thanks in advance.


Solution

  • The syntax of the select statement in Dynamics AX X++ code has no distinct keyword like it exists in SQL. There are workarounds, however:

    • Create a new table or enum that contains the possible values of the lookup field and do the lookup on that table or enum (that is the workaround I would recommend)
    • Create at runtime of the lookup a List of all the possible lookup values and then use the SysLookup::lookupList function