Message Definition, list external name - Mendix Forum

Message Definition, list external name

0

If You select in a message definition an associated object (1 *) which is a list, the external name will be have the following value:

Associated Object Name + 's'. That is incorrect as when you deserialize the exported JSON you will get errors on the List objects.
The external name should be the same as the domain model name of the association.
It is possible to override the external name with the correct association name, but this is inconvenient and if You are not aware of this issue it will take many hours to find the cause.

ticket 99313

asked
5 answers

I’ve tried it with both persistent and non-persistent entities, and both work.

Created

Hi Joost,

 

Then I am not sure what went wrong in my case ?

Did you use non persistent entities for the mapping ?

Created

I’ve tried it out, and it all seems to work fine. The default message definition for Person with the default import mapping for it is able to import that JSON. It creates 1 Person names “John Doe” and two Cars with brands “BMW” and “Volvo”.

Created

Hi Joost,

When you use the same message definition to import the Objects, I saw that the attributes (of Car) are not set, they remain empty.

This is probably due to the mismatch between the Cars external name and the real domain model name.

Created

Could you explain more about what you would consider incorrect about it?

Let’s say you have two entities with an association Person 1 ← * Car. The association is called Car_Person. You create a message definition for Person. By default, the JSON that gets exported/imported will look like this:

{
  "Name": "John Doe",
  "Cars": [
    { "Brand": "BMW" },
    { "Brand": "Volvo" }
  ]
}

If you prefer to change “Cars” to “Car_Person” then you can do that, but doesn’t it look nicer with “Cars”?

Created