0

Proplem

When creating Virtual Entities in Dynamics 365 (using the Odata v4 Provider)

According to MS documentation OptionSet fields cannot be mapped using Int and that enum should be used:

Below an example of an odata $metadata: Note statusCode uses enum ak_iglead_StatusCode and the values are string (although the source has them defined as int)

c# defined enum

Odata : $metadata

When Dynamics does an update to this Virtual Entity it seems that its posting the optionsetvalue on the form as int ( as it was mapped - I mean how else (only int values are used for an optionsetvalue)

Option set mapping

The result from the logstream shows that the json was malformed :

More Information:

The request could not be understood by the server due to malformed syntax.

IE, in postman I was expecting Dynamics to do this (and works):

![OptionSet value as string

BUT it did this (because of the mapping, I guess?)

![OptionSet value as Int

fiddler also confirms that the body send was:

{"ak_leadstatus":821220012}

Question

would the simplest fix be to get the **enum** values to also display as int values in $metadata? and how does one do that -is there some decoration I need on the PATCH? Or how else is an update handled using **enums**

or how do I get the PATCH body to do this :

{
    "@odata.context": "http://localhost:57838/$metadata#ak_igLeads(ak_Lead_StatusCode)/$entity",
    "statusCode@odata.type" : "#AK.IG.VirtualEntity.DataSource.Models.ak_iglead_StatusCode"**,
    "statusCode" : "New"
}
Shane_Yo
  • 770
  • 8
  • 24

0 Answers0