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 :
Microsoft Dynamics AX (Archived)

How to assign null or blank value to an extended data type/Enum type field in X++

(0) ShareShare
ReportReport
Posted on by

In a SSRS report DP class, I have a in memory table called bookingsTmp. I want some fields be blank in my report.  So I hard coded them as following: 

bookingsTmp.ProjectStage = ""; -----Data type of ProjectStage is EnumType ProjStatus

bookingsTmp.FiscalYear = ""; -----Data type of FiscalYear is ExtendedDataType  Year

bookingsTmp.ProjectBookedDate= ""; ---Data type of ProjectBookedDate is ExtendedDataType TransDate

I got error message "Operand types are not compatible with the operator". if I change 

bookingsTmp.ProjectStage =0; 

bookingsTmp.FiscalYear = 0; 

No compiler error. But there are values in my report. 

For the Date field ---bookingsTmp.ProjectBookedDate , I tried assign it 1900-01-01 , still get error. I also tried convert it to string, no luck. 

Basically, I  don't want to display any values in my report for those 3 fields. How to do it?

 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Anton Venter Profile Picture
    20,345 Super User 2025 Season 2 on at
    You have to do that in Visual Studio. Enums are integers in the database so you cannot assign empty strings to them.
  • dd1e280ab471435aa03a1f54a3dd72b8 Profile Picture
    40 on at

    You can use the nullValueFromType() method in the Global class.

    As written in this method, for enum, it will return 0.

  • Suggested answer
    Martin Dráb Profile Picture
    237,803 Most Valuable Professional on at

    What exactly is the purpose of hard-coding "empty" values and then displaying them in a report? You could simply use unbound controls without any value.

    Also, you have to realize what data type values actually means. Value 0 of an enum represents the element with ID == 0, e.g. No in NoYes enum. What is "blank value" of NoYes enum? The question doesn't makes sense. (I'm ignoring the option of setting an invalid value of an enum, because it goes against the purpose of enums.) But you surely can say "if the value is No, I want to show an empty string instead of the actual enum value" - that's what you can implement in an SSRS expression with IIF function.

  • Community Member Profile Picture
    on at

    Thanks everyone. I used IIF in visual studio to take care of what I need.

  • Community Member Profile Picture
    on at

    Martin,The purpose of hard-coding "empty" value is I need to add return POs to my booking report. Bookings are from projects. So I have to hard-code empty value to lots of project attributes for my return order's data set.

  • Suggested answer
    Shubham  Profile Picture
    65 on at

    AX does not have a null value concept. Instead the following values are considered "not entered" by defintion:

    string: blank

    int and int64: 0 (zero)

    enum: 0 (typically the first value)

    date: 01\01\1900 (displays as blank)

    For new base enums make a blank zero enum value (by convention name it None). This will make the use of mandatory fields possible for this enum type.

  • Deepak Agarwal Profile Picture
    8,598 on at

    For Date empty date try with DateNull() method instead of 1900-01-01.

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans