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 106
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
    Bharani Preetham Pe... 3,616 Moderator on at
    How to filter the value displayed in the reference group
    You missed adding a range in your query.
  • Suggested answer
    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
    Mohit Rampal 12,554 Moderator on at
    How to filter the value displayed in the reference group
  • Yue Zhen Profile Picture
    Yue Zhen 106 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
    Martin Dráb 231,321 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

Announcing Our 2025 Season 1 Super Users!

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

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,321 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans