Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Unanswered

How to update Enum property of a DataEntity using Odata in D365FO

(0) ShareShare
ReportReport
Posted on by 85

Hi,

I am trying to figure out how to update a property in DataEntity (for ex: SystemUsers) which is of type Enum (for ex: "Microsoft.Dynamics.DataEntities.Timezone")

Question 1:


There is a property "PreferredTimeZone" in SystemUser data-entity. This PreferredTimeZone property is defined as Enum as follows:

<Property Name="PreferredTimeZone" Type="Microsoft.Dynamics.DataEntities.Timezone">
                    <Annotation Term="Microsoft.Dynamics.OData.Core.V1.LabelId" String="Preferred time zone" />
                    <Annotation Term="Microsoft.Dynamics.OData.Core.V1.AXType">
                        <EnumMember>Microsoft.Dynamics.OData.Core.V1.AXType/Enum</EnumMember>
                    </Annotation>
 </Property>
Now, there is a EnumType defined with TimeZone as follows which has many entries, for ex. an entry for Hawaii is as follows:
<EnumType Name="Timezone">
.....
<Member Name="GMTMINUS1000HAWAII" Value="39">
          <Annotation Term="Microsoft.Dynamics.OData.Core.V1.LabelId" String="(GMT-10:00) Hawaii" />
     </Member>
....
</EnumType>
Currently, a SystemUser has PreferredTimeZone set as follows:
{
"PreferredTimeZone""GMT_COORDINATEDUNIVERSALTIME"
}
I want to change this, how should I do go about doing this? I have tried following things, please let me know
where am I going wrong and what are the things that I am missing to understand?
Here are my different attempts in changing the preferred time zone to GMTMINUS1000HAWAII
Request Type: PATCH, URL: https://<fo-base-url>/data/SystemUsers('NeerajUser2')
{
"UserID""NeerajUser2",
    "PreferredTimeZone" : "GMTMINUS1000HAWAII"
} ----> Get 204 status but the value is not updated
{
"UserID""NeerajUser2",
    "PreferredTimeZone" : "39"
} ----> Get 204 status but the value is not updated
{
"UserID""NeerajUser2",
    "PreferredTimeZone" : 39
} ----> Fails with "message""Cannot read the value '39' as a quoted JSON string value.",
{
"UserID""NeerajUser2",
    "PreferredTimeZone" : "Microsoft.Dynamics.DataEntities.Timezone'GMTMINUS1000HAWAII'"
} // Fails with: Requested value 'Microsoft.Dynamics.DataEntities.Timezone'GMTMINUS1000HAWAII'' was not found
{
"UserID""NeerajUser2",
    "PreferredTimeZone" : "Microsoft.Dynamics.DataEntities.Timezone'39'"
} // Fails with: Requested value 'Microsoft.Dynamics.DataEntities.Timezone'39'' was not found
I have tried various other combinations but not able to achieve what I want to do!
How do I verify if the value is updated? System Administration > Users > Select User > User Options > Preferences > Time zone
Question 2: There is other property "StartPage" which also seems to be an Enum and is defined as follows in the DataEntity:
(also, there are other properties defined similarly, taking "startpage" as an example)
<Property Name="StartPage" Type="Edm.String">
     <Annotation Term="Microsoft.Dynamics.OData.Core.V1.AXType">
          <EnumMember>Microsoft.Dynamics.OData.Core.V1.AXType/String</EnumMember>
     </Annotation>
 </Property>
But I am not able to see what are the values defined for this anywhere. How to check those?
Question 3:
How to get what are the values currently defined for the EnumType before updating them to avoid unnecessary errors?
For Ex: how to get (using Odata) the entries defined in the EnumType: Timezone before triggering the request to update
the Enum property of a DataEntity so that wrong values are not sent to avoid failure and retries.
Same for StartPage as well!
Thanks in advance.
Regards,
Neeraj
  • ToddB Profile Picture
    ToddB on at
    RE: How to update Enum property of a DataEntity using Odata in D365FO

    Hi Neeraj,

    I found the below thread:

    D365 Finance and operations odata for enums

    community.dynamics.com/.../d365-finance-and-operations-odata-for-enums

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

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans