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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Set local enum variable to null

(0) ShareShare
ReportReport
Posted on by 190

Hello everybody, 

I have a requirement where I need to set the value of TaxBookType enum to null. 

So what I did is that I used the nullValue method, but It returns the TaxBookType::NotIncluded(EnumValue = 0). 

public void myMethod()
{
    TaxBookType taxBookType;
    taxBookType = nullValue(taxBookType);

    info(strfmt("%1", taxBookType));
}

It prints Not Included.

Does anyone has any idea, if it is possible to assing nullValue to taxBookType enum? 

Thank you in advance. 

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    301,020 Super User 2025 Season 2 on at

    HI Eva,

    This is not possible when the enumeration's first value has a meaning. In this case it is NotIncluded. There are some other enumerations (not the one from your example) where a value 'None' with a blank label is used to indicate of there is no value selected.

    Can you tell about the background of your question?

  • Martin Dráb Profile Picture
    237,878 Most Valuable Professional on at

    null is used with referenced types, which isn't the case of enums. And there are no nullable references types as in C#.

    Valid values of an enum are its elements, nothing else. Technically, you can assing different numbers to the variable (because an enum is implemented as a number), but if you use a number that isn't used by any element, you get an invalid value.

  • GirishS Profile Picture
    27,827 Moderator on at

    Hi Eva,

    If you are using the enum control in form you can set null value by using "selection" method of the combo box control but the above one is not possible.

    Thanks...

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 646 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans