I am setting up Dualwrite at a customer and I got an issue the other day. The customer wants to be able to create customers from Dynamics 365 CE and syncing them to Dynamics 365 for FO. We had done all of the initial syncs and done multiple test for creating Accounts in CE and the synced perfectly to FO.
When I was trying to figure out a way to manage Financial Dimension population while creating accounts I tried creating the customer directly in FO, just to test a thing… and it failed!!
I tried again from CE and it worked… but not from FO. We had been so focused on testing one direction but not the other… Doh!
So, what was the issue? I got this error:
Unable to write data to entity accounts.Writes to CustCustomerV3Entity failed with error message Request failed with status code BadRequest and CDS error code : 0x80048d19 response message: Error identified in Payload provided by the user for Entity :'accounts', For more information on this error please follow this help link https://go.microsoft.com/fwlink/?linkid=2195293 ----> InnerException : Microsoft.OData.ODataException: Cannot convert the literal '' to the expected type 'Edm.Int32'. ---> System.FormatException: Input string was not in a correct format.
and then it continued with a stack trace… Hmmm…
So I started brainstorming with a colleague: It is obviously a data type missmatch and when I turn off the mapping for Account, it works. Going through the mapping we had added a few transform mappings so we started there. It turns out that all of these we 1 to 1 mappings. The problems was that there three fields were not on the initial “customer creation sidebar”. In CE these were made mandatory but in FO, they were not.

I took a look at the mappings for these 3 fields and one stood out. It had no mapping for the empty value.

This meant that when going from FO to CE I tried to convert and empty string to an integer and since there was no transform for the empty field and no default it could not be written to CE.
The easiest way to add an empty mapping to null is to edit the JSON version of the mapping (I did not know this was possible until a short while ago)
[
{
"transformType": "ValueMap",
"valueMap": {
"Dealer": "787980000",
"End user": "787980001",
"Nat OEM": "787980002",
"Reg OEM": "787980003",
"Int OEM": "787980004",
"Integrator": "787980005",
"Contractor": "787980006",
"Other": "787980007",
"": null
}
}
]
Add the last line and do not forget the comma at the end of the previous line
That was it… I saved it and restarted the mapping. We verified it… Worked!!!
That was it for today… see you around
Leave a Reply