web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How to Create a Dropdown with ReferenceGroup to Display Specific Data Only

(2) ShareShare
ReportReport
Posted on by 405

Hello everyone,

I have a specific scenario I want to implement. I have two tables: the first one is called ViolationGroup and the second one is ViolationTypes. In the first table, I have two fields: GroupCode and Description. Similarly, in the second table, I have ViolationCode and ViolationType, as well as a field that should be linked to the RecId of the ViolationGroup table.

I also have a form with a grid bound to the ViolationTypes table. I defined the fields of the ViolationTypes table in the grid. When I reached the GroupCode field, I wanted to create a dropdown list that displays all the data from ViolationGroup, and upon selecting any ViolationGroup, only the GroupCode should be displayed.

Here’s the code I implemented:
 

SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(ViolationGroup), sender);  
Query query = new Query();  

sysTableLookup.addLookupfield(fieldNum(ViolationGroup, ViolationGroupCode), true);  
sysTableLookup.addLookupfield(fieldNum(ViolationGroup, ViolationGroupDescription));  

QueryBuildDataSource qbds = query.addDataSource(tablenum(ViolationGroup));  
sysTableLookup.parmQuery(query);  

sysTableLookup.performFormLookup();  

FormControlCancelableSuperEventArgs ce = e as FormControlCancelableSuperEventArgs;  
ce.CancelSuperCall();  

However, the RecId of the field is still being displayed, so I resorted to using a Reference Group by following the instructions in this video:
https://www.youtube.com/watch?v=vpRrNL-GfbY

This was a suitable solution but not an optimal one. What I want is to display all the data from the ViolationGroup table, and upon selecting any field, only the field I specify (like GroupCode) should be displayed. However, the Reference Group tool displays the fields I’ve defined in the index of the table it’s linked to.

What I want to achieve is the ability to display all the data from the table using a Reference Group while maintaining the display of GroupCode in the cell—exactly as it works when selecting a customer in the Sales Order form.

I hope I’ve explained my issue clearly. If anything is unclear or needs further clarification, please let me know so I can elaborate further.

Categories:
I have the same question (0)
  • Suggested answer
    Waed Ayyad Profile Picture
    8,954 Super User 2025 Season 2 on at
    How to Create a Dropdown with ReferenceGroup to Display Specific Data Only
    Hi,
     
    You can set the replacement Field group to the field that you want, GroupCode in your case. create an index for the GroupCode and set alternate key property to Yes.

    Also check the following link: 
    reference-group-controls-in-dynamics-365-for-operations
     

    Thanks,

    Waed Ayyad

    If this helped, please mark it as "Verified" for others facing the same issue

     
  • Ali AbdAlNasser Profile Picture
    405 on at
    How to Create a Dropdown with ReferenceGroup to Display Specific Data Only

    Hello Waed Ayyad,
    I have already applied the content of this article and I still find the same problem, which is that all the fields I inserted into the Field Group appear in the cell, just like the person who wrote this article
  • Suggested answer
    Waed Ayyad Profile Picture
    8,954 Super User 2025 Season 2 on at
    How to Create a Dropdown with ReferenceGroup to Display Specific Data Only
     
    Did you create new index, set alternate key property to Yes, and create new field group to have only the Group Code, and set the replacement Field group to the new field group that you created?

    Can you show me screenshot of the properties of the reference group?

    Also, check the following link: reference-groups-in-d365-fo
     
     

    Thanks,

    Waed Ayyad

    If this helped, please mark it as "Verified" for others facing the same issue.

  • Layan Jwei Profile Picture
    8,034 Super User 2025 Season 2 on at
    How to Create a Dropdown with ReferenceGroup to Display Specific Data Only
    Hi Ali,

    Field groups decide what appears when you select a value from the drop down of a reference group.
     
    What's the unique index of ViolationGroup table (I mean the index with allow duplicate = No)?
    If the unique index of 'ViolationGroup' is GroupCode
    then just fill the replacement key property of  'ViolationGroup' table as GroupCode
     
    but if the unique index of ViolationGroup table is not GroupCode alone
    then create a new fieldGroup with GroupCode

    and in the form, where you added the reference group field, fill the replacement group property of this control with this new fieldGroup
     

    Thanks,
    Layan Jweihan
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future.

  • Waed Ayyad Profile Picture
    8,954 Super User 2025 Season 2 on at
    How to Create a Dropdown with ReferenceGroup to Display Specific Data Only

    Hi, 

    Is your issue resolved? If yes, mark the answers that helped you as verified. 

    Thanks,

    Waed Ayyad

  • Ali AbdAlNasser Profile Picture
    405 on at
    How to Create a Dropdown with ReferenceGroup to Display Specific Data Only
    Hello Waed Ayyad.
    I apologize for my delay in responding to your answer.
    Regarding your first question about the field group, yes, I have created one already and placed it in ReplacementFieldGroup, but I did not get the ideal result.

    I will share with you pictures of the steps I followed so that you have a complete idea of what I want:


    As shown in the pictures, I do not want to display the description with the group code in the field; rather, I only want it to be displayed in the dropdown list.
  • Suggested answer
    Waed Ayyad Profile Picture
    8,954 Super User 2025 Season 2 on at
    How to Create a Dropdown with ReferenceGroup to Display Specific Data Only
    Hi,
     
    Your steps are correct, but since it seems the unique index for your table is ViolationGroupCode , and ViolationGroupDescriotion, the replacement field will show both fields on the form control.
     
    You can follow the following steps to create new index and replacement key.

    1- Create new index on the table call it ViolationGroupCodeIdx , add ViolationGroupCode  to it, set alternate key property to Yes.

    2- Create new field group call it ViolationGroupCodeGrp to have only the ViolationGroupCode field.
     
    3-Set the replacement Field group on the form control to the new ViolationGroupCodeGrp that you created.
     
    I have one question also, what is the unique index for your table?
     
    Follow the steps and tell me the result.
     

    Thanks,

    Waed Ayyad

    If this helped, please mark it as "Verified" for others facing the same issue

  • Layan Jwei Profile Picture
    8,034 Super User 2025 Season 2 on at
    How to Create a Dropdown with ReferenceGroup to Display Specific Data Only
    Hi Ali,

    I already gave you the answer in my previous reply.

    I said if the unique index of your table is not just GroupCode which is your case, then Just create a new field Group in "ViolationGroup" table and only put in it GroupCode
     
    and in the form control property, fill the replacement field group property with the new field group

    or just modify the existing field group and remove the description from it.
    ​​​​​​​
    No need to create new indexes
     

    Thanks,
    Layan Jweihan
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future.

  • Waed Ayyad Profile Picture
    8,954 Super User 2025 Season 2 on at
    How to Create a Dropdown with ReferenceGroup to Display Specific Data Only
     
    Check my asnwer from yesterday and my clarification answer today based on your screenshots and tell me the result.
     
    If my answers help you, please mark it as verified.
     
    Thanks,
    Waed Ayyad
     
     

     

     
     
     
     
  • Ali AbdAlNasser Profile Picture
    405 on at
    How to Create a Dropdown with ReferenceGroup to Display Specific Data Only

    Hello Layan Jwei and Waed Ayyad,
    I have tried applying the same steps that were explained to me in detail, but I am still getting the same result.

    When I set GroupCode as an index or as a Field Group, I get a dropdown list with Group Code. However, if I include the GroupDescription field in the index, I get two fields in the dropdown list and in the cell displaying data for the ViolationGroup table. The same applies to the Field Group.

    As for the unique index in my table, it is ViolationGroupCode.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,122

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 918 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 646 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans