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

NoYes Enum gets an empty value

(0) ShareShare
ReportReport
Posted on by 15

Hello people, 

I have a field in a table which extends EDT NoYesId (which extends Enum NoYes). 

I have a form with some records of this table and the tick is present in the corresponding field checkbox. 

When I run through these records using x++ and showed the value of the field in the infolog, it gave me just a blank result. 

When I looked directly in SQL database, I found the value of 255. 

Somehow, as I understand, the maximal SQL datatype tinyint value has been assigned. 

Any ideas what could be the reason of it? 

Thanks

  • edgcibu Profile Picture
    edgcibu 15 on at
    RE: NoYes Enum gets an empty value

    I found the wrong assignment when importing the enum value from .csv file, from the wrong column. str2enum function is used and when tries to convert unrelated string, I got blank in AX. I think will do some check here, either it is 1 or put 0 otherwise.

    thanks for your time

  • Martin Dráb Profile Picture
    Martin Dráb 231,305 Most Valuable Professional on at
    RE: NoYes Enum gets an empty value

    I've seen a case where developers were intentionally setting an enum value to 255 to get something like a null value (neither Yes or No; an unselected value). But it's not good design.

  • edgcibu Profile Picture
    edgcibu 15 on at
    RE: NoYes Enum gets an empty value

    I agree, therefore the question was what is the possible reason of getting such corrupted data.

    I will search for the field assignment, maybe something is wrong there.

  • Martin Dráb Profile Picture
    Martin Dráb 231,305 Most Valuable Professional on at
    RE: NoYes Enum gets an empty value

    No, you confuse enums with the underlaying type (integer). The only valid values of an enum are values of its elements (0 and 1 in this case) That the numeric field stored in the database can have other values is true, but they're not valid values of that enum. It's technically possible to set invalid value, but you can't expect the system to work with such corrupted data.

  • Blue Wang Profile Picture
    Blue Wang on at
    RE: NoYes Enum gets an empty value

    HI Edgcibu,

    Are you getting the value through code?

    Maybe this will help:

    community.dynamics.com/.../enum-noyes-type-has-wrong-value

  • edgcibu Profile Picture
    edgcibu 15 on at
    RE: NoYes Enum gets an empty value

    Isn't it that every enum can get up to 256 values what corresponds to sql tinyint datatype (even if it is system enum NoYes)? and we just define in Ax how many of them to use

  • Martin Dráb Profile Picture
    Martin Dráb 231,305 Most Valuable Professional on at
    RE: NoYes Enum gets an empty value

    I don't know how you got into this situation, but your database contains invalid data. The valid values are 0 (No) and 1 (Yes); 255 doesn't belong to this enum.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,489 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans