Create a new entry with association
Create a new entry with association
I have a problem to create new entry with association to existing entity.
In fact, I have 2 tables database, one is PERSONNEL (called T024) and another is PLANNING (called T027).
The relationship between them is manyTomany, it means that a person has many plannings and a planning has many persons.
I have created a person (ID_PERSONNEL: ‘T02400004’)
Another person (ID_PERSONNEL: ‘T02400005’)
And created also a planning (ID_PLANNING: 4)
I would like create a “link” between this planning with 2 persons
Can you give me some advice please?
Here is my oData/$metadata
<EntityType Name="T024">
<Key>
<PropertyRef Name="ID_PERSONNEL"/>
</Key>
<Property Name="FIRSTNAME_PERSONNEL" Type="Edm.String"/>
<Property Name="ID_PERSONNEL" Type="Edm.String" Nullable="false"/>
<Property Name="LASTNAME_PERSONNEL" Type="Edm.String"/>
<NavigationProperty Name="T027Details"
Relationship="AtosForm.T027_T024_Many_Many0" FromRole="T024"
ToRole="T027"/>
</EntityType>
<EntityType Name="T027">
<Key>
<PropertyRef Name="ID_PLANNING"/>
</Key>
<Property Name="ID_PLANNING" Type="Edm.Int32" Nullable="false"/>
<Property Name="BEG_DATETIME" Type="Edm.DateTime"/>
<Property Name="END_DATETIME" Type="Edm.DateTime"/>
<NavigationProperty Name="T024Details"
Relationship="AtosForm.T027_T024_Many_Many0" FromRole="T027"
ToRole="T024"/>
</EntityType>
Here is my code js:
var oUpdatePersonnel = {};
oUpdatePersonnel.T027Details = {
__metadata: {
uri: "/T027Details(4)"
}
};
oModelCont.update("/T024s('T02400000')/$links/T027Details",oUpdatePersonnel, {
success: function(oData) {},
error: function(oError) {}
});
And Error:
log-dbg.js:412 2018-06-25 19:03:04.847399 The following problem occurred: HTTP request failed400,Bad Request,{"error":{"code":null,"message":{"lang":"en","value":"The request body is malformed."}}}
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Comments
Post a Comment