Reputation: 213
I want to update _parentcustomerid_value
in the Contact entity (and some other) but I face such a problem - The property provided was of type System.Object, when the expected was of type System.Guid
I used this link to update entity attributes. Can anyone suggest me what to do? Maybe I'm doing something wrong or it's not possible to update ids
.
Upvotes: 1
Views: 565
Reputation: 22846
For lookup attribute, you have to use single valued navigation property and not the lookup property.
entity["[email protected]"] = "/contacts(DFE54660-37CD-E511-80DE-6C3BE5A831DC)"
The full code will look like this:
// define the data to update a record
var data =
{
"[email protected]": "/contacts(DFE54660-37CD-E511-80DE-6C3BE5A831DC)"
}
// update the record
Xrm.WebApi.updateRecord("contact", "61a0e5b9-88df-e311-b8e5-6c3be5a8b200", data).then(
function success(result) {
console.log("Contact updated");
// perform operations on record update
},
function (error) {
console.log(error.message);
// handle error conditions
}
);
Upvotes: 1