Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Save enum label to a field

(0) ShareShare
ReportReport
Posted on by 897

Hi guys,

What will be the correct way of saving enum label to a field with string type ?

When I have a field, lets say MyProjInvoiceStatus (string) then in my code I want to keep the label, I found out I cannot use function Enum2Str()

I have a code that compare the status and when it meets the condition, I would directly put the enum like for example [mytable].MyProjInvoiceStatus = enum2Str(ProjInvoiceStatus::FullyInvoiced)

That one as mentioned is wrong, so what would be the correct way of doing it ?

Thanks,

.

  • Tony zhong Profile Picture
    897 on at
    RE: Save enum label to a field

    Hi Nikolaos,

    It would be simpler in regards of the data will be used for FACT table as it will need to de-normalized. There is no need to be in separate table like a master or lookup table for this statuses. By just exposed the description, we no need to take care what is the meaning of value 1/2/3. Also we do not need the index as we also do not need the order sequence.

    However understand your concern, as and when the value needed, I will just added it as another column. Thanks for the input.

    rgds,

  • Verified answer
    nmaenpaa Profile Picture
    101,156 Moderator on at
    RE: Save enum label to a field

    How would it be simpler than actual enum value? To me it sounds like a design decision that will just hurt you in the future.

    Anyway you can use strFmt("%1", myTable.MyEnumField) to get the label in your language.

  • Tony zhong Profile Picture
    897 on at
    RE: Save enum label to a field

    Hi Martin,

    Yes, to simplify the table because it is for FACT table, and would like to use English as the international language.

    Thanks.

  • Martin Dráb Profile Picture
    231,748 Most Valuable Professional on at
    RE: Save enum label to a field

    Why don't you simply store the enum as en enum?

    Do you want to store the actual text (such as "Invoiced" or a label ID (such as @SYS12345?

    If the text, do you realize that it will stopped being translated to user's (and customers' etc.) language? Are you sure you want it? If so, which language do you want to use?

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

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

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 231,748 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans