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, ...
Suggested Answer

How to set enum value without using enum type

(0) ShareShare
ReportReport
Posted on by 10

str2Enum(enumType,enumvalue)

I have the same question (0)
  • Community Member Profile Picture
    on at

    can you please elaborate more on what is your requirement?

  • D365_Wibes Profile Picture
    184 on at

    Hi Muthu,

    Thanks for your response.

    Actually I have a requirement for Bulk Update for which I am using SysDataObject.

    And I am selecting tables dynamically via DictTable.

    Here the problem comes with fields whose base types are enum.

    I have tried the global conversion str2Enum(),  but the problem here is I cannot pass the enum type dynamically as it could be any thing such as (Gender,HcmPersonGender,PurchStatus etc.,)

    Please suggest if there any way where we can use str2Enum() and could pass the enum type dynamically...

  • Community Member Profile Picture
    on at

    Ok, please check the below link and hope this would help

    ahmad-assaf.blogspot.com/.../how-to-loop-through-enum-in-dynamics-ax.html

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

    What do you have an the input? How do you know what value you should put into which field?

  • D365_Wibes Profile Picture
    184 on at

    var uo = new SysDaUpdateObject(commonBuffer);
    
                uo.settingClause().add(maskedvalConfig.DataFieldName, new SysDaValueExpression(maskedvalConfig.DataFieldMaskedValue));

    Hi Martin,

    We have handled that as per the code pasted.

    Currently for fields based of enums no data is getting stored and that's where we require help ?

    We wanted to pass the value in  SysDaValueExpression()

  • D365_Wibes Profile Picture
    184 on at

    Thanks Muthu let me check and get back to you.

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

    What value do you have in your maskedvalConfig.DataFieldMaskedValue variable?

  • D365_Wibes Profile Picture
    184 on at

    Hi Martin,

    If the field is based of an Enum.

    Lets say if its based of "HcmPersonGender" then we are passing value either "Male" or "Female".

    As you see we are passing the values as string thought the field is based of an enum and that's where we tried to use str2Enum() but we hanged with enum type as we cannot pass it dynamically..

  • D365_Wibes Profile Picture
    184 on at

    Hi Martin,

    It will have a string value.

    I mean if a field is based of an enum lets say "HcmPersonGender" then the maskedValConfig.DataFieldMaskedValue would have "Male","Female" as string.  And this is where we are having problem that no value is being saved in such case.

    And hence we tried the conversion str2Enum() but unfortunately we could not as was unable to pass the enum type dynamically

    could you please provide some suggestion here?

  • D365_Wibes Profile Picture
    184 on at

    Hi Martin,

    The value in maskedValConfig.DataFieldMaskedValue is a string.

    I mean if the field is based of an enum then since we can't pass it as the same type we are passing it as a string value.

    Because our custom table field is a string field.

    hence we tried to use the global conversion str2Enum,however we could not as we cannot pass the enum type dynamically..

    Please suggest if there is any possibility to achieve this.

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 451 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans