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, ...
Suggested Answer

I need to control the visibility of enum values in a dropdown dynamically, based on existing data.

(0) ShareShare
ReportReport
Posted on by
Hi Everyone,

I have a requirement in Dynamics 365 Finance & Operations where I need to control the visibility of enum values in a dropdown dynamically, based on configuration and existing data.
Context
We have a master form AcxCustomerEntry that contains a combo box field:
Installment Frequency (EventFrequency enum)
The enum includes the following values (in required display order):
  • OneTime
  • Daily
  • Weekly
  • Monthly
  • Fortnightly
Business Requirements
Certain enum values should be hidden dynamically in the dropdown based on configuration defined in the ACXParameter table.
Example fields: EnableOneTime, EnableWeekly, EnableMonthly, etc.
Even if a frequency is disabled in parameters, it must still appear in the dropdown if there exists a record in ACXEventTable where:
 
  •  [Control("ComboBox")]
     class AcxCustomerEntry_InstallmentFrequency
     {
      
    
     public void lookup()
     {
       ACXParameter    param = ACXParameter ::find();
       DictEnum                dictEnum = new DictEnum(enumNum(EventFrequency ));
       int                     i, enumCount;
       boolean                 enabled, releasedExists;
       ACXEventTable           ACXEventTable ;
    
       enumCount = dictEnum.values();
    
       for (i = enumCount - 1; i >= 0; i--)
       {
         EventFrequency  freq = i;
    
         enabled = false;
         releasedExists = false;
    
         switch (freq)
         {
           case EventFrequency ::OneTime:
             enabled = param.EnableOneTime;
             break;
    
           case EventFrequency ::Daily:
             enabled = param.EnableDaily;
             break;
    
           case EventFrequency ::Weekly:
             enabled = param.EnableWeekly;
             break;
    
           case EventFrequency ::Monthly:
             enabled = param.EnableMonthly;
             break;
    
           case EventFrequency ::Fortnightly:
             enabled = param.EnableFortnightly;
             break;
         }
    
         // Check released Event existence
         select firstonly RecId
             from ACXEventTable 
             where ACXEventTable .InstallmentFrequency == freq
                && ACXEventTable .EventStatus == EventStatus ::Release;
    
         releasedExists = ACXEventTable .RecId ? true : false;
    
    
         if (!(enabled || releasedExists))
         {
           this.delete(dictEnum.index2Label(i));
         }
       }
     }
    
     }
    InstallmentFrequency == that enum value
    EventStatus == Released

    Can we do Dynamic Filtered Enum Lookup  or should i create a table for these enum fields and use query-based lookup control. If the enum one is possible then that would be helpful. 

    Please feel free to ask if you have any queries about my issue.

    Thanks,
    Ayushaman
Categories:
I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,455 Most Valuable Professional on at
    I need to control the visibility of enum values in a dropdown dynamically, based on existing data.
    It can be done with SysFormEnumComboBox class. Use references to find examples in the standard application.
     
    But consider replacing all the Enable* fields with a table, where you'll simply add records for enabled values. A benefit of it is that you don't need to create a new field and changing your lookup code when a new element is added to the enum.
  • Suggested answer
    Waed Ayyad Profile Picture
    9,013 Super User 2025 Season 2 on at
    I need to control the visibility of enum values in a dropdown dynamically, based on existing data.
     
     

     

     

    Thanks,

    Waed Ayyad

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

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 725 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
CU05031448-0 Profile Picture

CU05031448-0 468

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans