Skip to main content
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

editSubscribe (0) ShareShare
ReportReport
Posted on by 68
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?
 
Attachments
  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,430 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 48 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,538 Super User on at
    How to filter the value displayed in the reference group
  • Yue Zhen Profile Picture
    Yue Zhen 68 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 222,689 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

New Blog Features Released!

Check out the new community blog features for viewers and authors…

Setting Up Knowledge Sources for Copilot…

Look at how configuring a comprehensive knowledge base is crucial…

Demystifying Copilot with Georg Glantschnig…

Industry experts answer burning questions directly from our amazing Community…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,130 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 222,689 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,138

Featured topics

Product updates

Dynamics 365 release plans