web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

XRM Web Api (create record) - issues creating a note (annotation) with an object ID specified

(1) ShareShare
ReportReport
Posted on by 17

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!

I have the same question (0)
  • Verified answer
    cloflyMao Profile Picture
    25,210 on at

    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);
        }
    );

    pastedimage1610594357421v1.png

    You can refer to this article for more details about how to create annotation and associate it to an entity.

    https://community.dynamics.com/365/b/dynamics365enterprisecloudfronts/posts/create-notes-attachment-using-webapi

    Regards,

    Clofly

  • HerbMa Profile Picture
    17 on at

    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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 184 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 125

#3
CU11031447-0 Profile Picture

CU11031447-0 100

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans