web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / Delete Enum values dur...
Finance forum

Delete Enum values during runtime

(0) ShareShare
ReportReport
Posted on by 30

Hi Guys,

I have a requirement where i have to delete/hide an enum value for a specific form.

I used Enter event handler to delete the enum value, but it  does not work. Here is my code below.

[FormControlEventHandler(formControlStr(MCRCustSearch, CustSearchType), FormControlEventType::Enter)]
public static void CustSearchType_OnEnter(FormControl sender, FormControlEventArgs e)
{
    FormComboBoxControl formComboBoxControl = sender;

    formComboBoxControl.delete(enum2Str(MCRCustSearchType::AVACostCenter));
}

But, when i click the drop down first time, my value "Cost Center" is shown.

0447.Before-Click.PNG

After i change the value in the drop down, my code in Enter method is hit and my value is deleted.

4331.After-click.PNG

Since the field is an unbound combo box, i tried using SysFormEnumComboBox to display the values i want. But it doesn't work either. 

I have the same question (0)
  • Suggested answer
    gaurav.d365fo Profile Picture
    5 on at

    Hi ,

    The best way to achieve this is to override the initvalue method of datasource

    and you can use below code.

     public void initValue()

     {

         super();    

         FormComboBoxControl.delete((enum2Str(MCRCustSearchType::AVACostCenter));;

      }

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans