Skip to main content

Notifications

Dynamics 365 Community / Forums / Finance forum / How to filter the valu...
Finance forum
Suggested answer

How to filter the value displayed in the reference group

Posted on by 79
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,528 Super User 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
    Nisha Soni 2709 60 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
    Mohit Rampal 12,540 Super User on at
    How to filter the value displayed in the reference group
  • Yue Zhen Profile Picture
    Yue Zhen 79 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 227,174 Super User 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.)

Helpful resources

Quick Links

Dynamics 365 Community Update

Welcome to the inaugural Community Platform Update. As part of our commitment to…

Dynamics 365 Community Newsletter - August 2024

Catch up on the latest D365 Community news

Community Spotlight of the Month

Kudos to Waed Ayyad!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 289,995 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 227,174 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans