I have gone through many posts on here and I have not gotten any to work. So obviously I am doing something wrong.
I have 2 custom tables, new_pres_client (Pres_Client) & new_presclienthistory (Pres Client History)
I am attempting to create a record in the new_presclienthistory table when a change happens on the new_pres_client record.
If I just fill in the changes column it works fine, but when attempting to fill in the Lookup I get continuous errors.
function createClientHistory_OnSave() {
varcurID = Xrm.Page.data.entity.getId().slice(1,-1);
var newRecord =
{
"new_changes": "Some Random Text",
"new_client@odata.bind": "/new_pres_clients(" varcurID ")"
}
Xrm.WebApi.createRecord("new_presclienthistory", newRecord);
}
Error:
An error occurred while validating input parameters: Microsoft.OData.ODataException: An undeclared property 'new_client' which only has property annotations in the payload but no property value was found in the payload. In OData, only declared navigation properties and declared named streams can be represented as properties without values.
During my troubleshooting if I change the "new_client" to anything else I receive the same error.
Thank you for any assistance.
Guido Preite Yup, that fixed it, I was so close.
Here is the fixed code:
var curID = Xrm.Page.data.entity.getId().slice(1,-1); var record = {}; record.new_changes = "List of Edits"; //Multiline Text record["new_Client@odata.bind"] = "/new_pres_clients(" curID ")"; //Lookup Xrm.WebApi.online.createRecord("new_presclienthistory", record);
can you try with my tool Dataverse REST Builder how the Xrm.WebApi syntax is generated?
If I remember correctly there goes the navigation property
OK, so I have been going through the documentation and from what I can tell I am following it to the letter, so I must be missing something. Below is the Microsoft example and mine, I'm not seeing where the issue is.
Example: docs.microsoft.com/.../createrecord
//Microsoft var data = { //text field to change "name": "Sample Account", //the Logical Name of the column "primarycontactid" //the EntitySetName of the lookup "contacts" "primarycontactid@odata.bind": "/contacts(465b158c-541c-e511-80d3-3863bb347ba8)" } //the Logical Name of the written to table "account" Xrm.WebApi.createRecord("account", data) //Mine var data = { //text field to change "new_changes": "Sample Account", //the Logical Name of the column "new_client" //the EntitySetName of the lookup "new_pres_clients" "new_client@odata.bind": "/new_pres_clients(465b158c-541c-e511-80d3-3863bb347ba8)" } //the Logical Name of the written to table "new_presclienthistory" Xrm.WebApi.createRecord("new_presclienthistory", data)
Adis
136
Super User 2025 Season 1
Sohail Ahmed
81
Jonas "Jones" Melgaard
77
Super User 2025 Season 1