I've been looking to add a feature where using client side script, we would like to create a note (annotation). I've been able to create a note but haven't been able to assign it to a custom entity. Here is the client side code we're using:
var clientID = formContext.getAttribute("client").getValue()[0].id; // define the data to create new annotation var data = { "subject": "Client Interaction", "notetext": "Client Interaction logged", "isdocument": false, "objectid": { "logicalname": "custom_client", "custom_clientid": clientID } } // create annotation (note) record Xrm.WebApi.createRecord("annotation", data).then( function success(result) { console.log("Note created with ID: " result.id); // perform operations on record creation }, function (error) { console.log(error.message); // handle error conditions } );
I'm successfully able to create the annotation (note) if I remove the objectid property but we really want to create the note so it's regarding (linked) to the custom entity client. The error we see in the console is:
An error occurred while validating input parameters: Microsoft.OData.ODataException: Does not support untyped value in non-open type.
Any help would be greatly appreciated!
Hi Clofly,
Thank you so much! That did the trick, I misunderstood the specs for objectid. I updated my code set as per your suggestion and it works perfectly. Many thanks! (I was stuck for quite some time).
Herb
Hi HerbMa,
The error indicates that we are passing a property of a JSON object(the data variable in your code) that doesn't exist on the data model(objectid can't be used directly).
Instead, please change the data object to following:(e.g: I have a custom entity called Doctor.)
var data =
{
"subject": "Client Interaction",
"isdocument": false,
"notetext": "Client Interaction logged",
"objectid_new_doctor@odata.bind": "/new_doctors(3f4f2e69-1356-eb11-a812-00224816bc2d)",
"objecttypecode": "new_doctor"
};
Xrm.WebApi.online.createRecord("annotation", data).then(
function success(result) {
var newEntityId = result.id;
console.log("Note created with ID: " newEntityId);
},
function(error) {
Xrm.Utility.alertDialog(error.message);
}
);
You can refer to this article for more details about how to create annotation and associate it to an entity.
Regards,
Clofly
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,524 Super User 2024 Season 2
Martin Dráb 228,469 Most Valuable Professional
nmaenpaa 101,148