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