Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

How to filter the value displayed in the reference group

(0) ShareShare
ReportReport
Posted on by 137
Hi, I have a question related to Dynamics 365 Finance and Operations.
 
I created a reference group control in my MainAccount form which will look up to the Category Hierarchies (EcoResCategory) table. In the reference group lookup field, I need it to display only the record where the EcoResCategory.CategoryHierarchy = '68719480517'.
 
However, when I checked, there is no LookupReference() method for the created reference group control in the MainAccount form code. Hence, I try to use the Chain of Command to extend the MainAccount form code and add a public Common lookupReference() method, but it does not work. The code that I wrote is as follows:
 
[ExtensionOf(formStr(MainAccount))]
final class MainAccount_Classification_Extension
{
    [Control(/ReferenceGroup/)]
    class EcoResCategory
    {
        public Common lookupReference(FormReferenceControl _formReferenceControl)
        {
            SysReferenceTableLookup sysReferenceTableLookup;
            Query query;
            QueryBuildDataSource qbds;
            sysReferenceTableLookup = SysReferenceTableLookup::newParameters(tableNum(EcoResCategory), _formReferenceControl);
            sysReferenceTableLookup.addLookupfield(fieldNum(EcoResCategory,Code));
            sysReferenceTableLookup.addLookupfield(fieldNum(EcoResCategory,Name));
            query = new Query();
            qbds = query.addDataSource(tableNum(EcoResCategory));
            qbds.addQueryFilter(qbds, fieldStr(EcoResCategory,Code)).value('!//');
            sysReferenceTableLookup.parmQuery(query);
            return sysReferenceTableLookup.performFormLookup();
        }
    }
}
May I know how to resolve it so I can have the reference group field display the records that match my condition only?
 
  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,624 Moderator on at
    How to filter the value displayed in the reference group
    You missed adding a range in your query.
  • Suggested answer
    Nisha Soni 2709 Profile Picture
    on at
    How to filter the value displayed in the reference group
    you need to filter a field which refer to your reference field because reference field cannot be filter directly, your reference field should filter automatically.
  • Suggested answer
    Mohit Rampal Profile Picture
    12,556 Moderator on at
    How to filter the value displayed in the reference group
  • Yue Zhen Profile Picture
    137 on at
    How to filter the value displayed in the reference group
    Hi Sir Martin,
     
    It means when debugging, the code is hit but I cannot trigger it. The reference group lookup options is not filter based on the condition I wrote in the lookupReference() method.
  • Martin Dráb Profile Picture
    231,939 Most Valuable Professional on at
    How to filter the value displayed in the reference group
    What do you mean by "it does not work"?
     
    (Moved from Dynamics AX forum.)

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,274 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,939 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans