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

Community site session details

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

Create an Entity Record using "Xrm.WebApi.createRecord" in JS

(0) ShareShare
ReportReport
Posted on by 97

I was trying to Create an entity record using "Xrm.WebApi.createRecord" but I'm getting the Following error

"An error occurred while validating input parameters: Microsoft.Crm.CrmException: Invalid property 'edm_donorid' was found in entity 'Microsoft.Dynamics.CRM.edm_bookreceiptdetail'. ---> Microsoft.OData.ODataException: Does not support untyped value in non-open type."

please not that I'm sure that the field 'edm_donorid' exists in the form.

 

 var data =
                        {
                            "edm_donorid": {
                                "logicalname": "contact",
                                "id":   result["_edm_donorid_value"]
                            } 
                           
                        };
                        opener.Xrm.WebApi.createRecord("edm_bookreceiptdetail", data).then(
                            function success(record) {
                                console.log("record created with ID: "   record.id);
                                // perform operations on record creation
                            },
                            function (error) {
                                console.log(error.message);
                                // handle error conditions
                            }
                        );

I have the same question (0)
  • Verified answer
    Amer Azzam Profile Picture
    97 on at
    RE: Create an Entity Record using "Xrm.WebApi.createRecord" in JS

    Hello,

    Thank you all for your replies and your answers. I found the problem and I fixed it.

    "cannot find record to be updated" error comes when I disregarded to fill a field that that have a relation with another entity.

    so, make sure to fill every mandatory field or fields related to any other entities when you create an entity record using JS.

    best regards,

    Amer Azzam,

    Microsoft Dynamics 365 Developer

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Create an Entity Record using "Xrm.WebApi.createRecord" in JS

    Hi Amer,

    Based on the code "result["_edm_donorid_value@Microsoft.Dynamics.CRM.associatednavigationproperty";", you retrieved another entity to get customer field value to create new records, Right?

    I test with following code, which run successfully.

    function createRecords(executionContext) {
        var formContext = executionContext.getFormContext();
        Xrm.WebApi.online.retrieveRecord("incident", "5dda2b2e-d785-4474-b324-6225d4931000", "?$select=_customerid_value").then(
            function success(result) {
                var entity = {};
                var type = result["_customerid_value@Microsoft.Dynamics.CRM.associatednavigationproperty"];
                if (type == "customerid_contact") {
                    entity["parentcustomerid_contact@odata.bind"] = "/contacts("   result["_customerid_value"]   ")";
                }
                else if (type == "customerid_account") {
                    entity["parentcustomerid_account@odata.bind@odata.bind"] = "/accounts("   result["_customerid_value"]   ")";
                }
    
                Xrm.WebApi.createRecord("contact", entity).then(
                    function success(record) {
                        console.log("record created with ID: "   record.id);
                        // perform operations on record creation
                    },
                    function (error) {
                        console.log(error.message);
                        // handle error conditions
                    }
                );
            },
            function (error) {
                Xrm.Utility.alertDialog(error.message);
            }
        );
    }

    Can you provide full code and more details of your scenario.

    Or you can try to use power automate(https://us.flow.microsoft.com/en-us/) not code to create new records, which may be achieved more easily.

    Use the Add a new row action to add a new row in Microsoft Dataverse.

    Use a flow to add a row in Dataverse - Power Automate | Microsoft Docs

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Create an Entity Record using "Xrm.WebApi.createRecord" in JS

    Please, don't create a new thread with exactly the same name - it is confusing.

    Either close the thread marking the answer or keep adding new replies to the existing thread if something doesn't work/you need more details.

    Merging those 3 threads you created.

  • Amer Azzam Profile Picture
    97 on at
    Create an Entity Record using "Xrm.WebApi.createRecord" in JS

    I was trying to Create an entity record using "Xrm.WebApi.createRecord" but I'm getting the Following error.

    "cannot find record to be updated"

    please not  that the field 'edm_donorid' exists in the form and the ID that I'm using to fill the fill also exists in the contacts.

                          var entity = {};
                           var type= result["_edm_donorid_value@Microsoft.Dynamics.CRM.associatednavigationproperty"];
                           if(type== "edm_DonorID_contact")
                           {
                            entity["edm_DonorID_contact@odata.bind"] = "/contacts("   result["_edm_donorid_value"]   ")";
                           }
                           else if(type== "edm_DonorID_account")
                           {
                            entity["edm_DonorID_account@odata.bind"] = "/accounts("   result["_edm_donorid_value"]   ")";
                           }
    
                            opener.Xrm.WebApi.createRecord("edm_bookreceiptdetail", entity).then(
                                function success(record) {
                                    console.log("record created with ID: "   record.id);
                                    // perform operations on record creation
                                },
                                function (error) {
                                    console.log(error.message);
                                    // handle error conditions
                                }
                            );
    


  • Suggested answer
    Amer Azzam Profile Picture
    97 on at
    RE: Create an Entity Record using "Xrm.WebApi.createRecord" in JS

    hello,

    I fixed the error.

    the field that i was trying to fill is of Type "Customer" and not "Lookup" so  i fixed that by using the following code.

                           var entity = {};
                           var type= result["_edm_donorid_value@Microsoft.Dynamics.CRM.associatednavigationproperty"];
                           if(type== "edm_DonorID_contact")
                           {
                            entity["edm_DonorID_contact@odata.bind"] = "/contacts("   result["_edm_donorid_value"]   ")";
                           }
                           else if(type== "edm_DonorID_account")
                           {
                            entity["edm_DonorID_account@odata.bind"] = "/accounts("   result["_edm_donorid_value"]   ")";
                           }

  • Suggested answer
    Amer Azzam Profile Picture
    97 on at
    RE: Create an Entity Record using "Xrm.WebApi.createRecord" in JS

    Hello,

    Thank You all for your replies.

    I fixed the error.

    the field that i was trying to fill is of Type "Customer" and not "Lookup" so  i fixed that by using the following code.

                           var entity = {};
                           var type= result["_edm_donorid_value@Microsoft.Dynamics.CRM.associatednavigationproperty"];
                           if(type== "edm_DonorID_contact")
                           {
                            entity["edm_DonorID_contact@odata.bind"] = "/contacts("   result["_edm_donorid_value"]   ")";
                           }
                           else if(type== "edm_DonorID_account")
                           {
                            entity["edm_DonorID_account@odata.bind"] = "/accounts("   result["_edm_donorid_value"]   ")";
                           }

  • Amer Azzam Profile Picture
    97 on at
    RE: Create an Entity Record using "Xrm.WebApi.createRecord" in JS

    hello Steve,

    I faced the same problem when I changed it to the schema Name.

  • Suggested answer
    Bipin D365 Profile Picture
    28,981 Moderator on at
    RE: Create an Entity Record using "Xrm.WebApi.createRecord" in JS

    Hi,

    I would advise you to download Rest Builder tool on your crm instance.

    jlattimer.blogspot.com/.../crm-rest-builder-v2600.html

    Tool will help you generate code for you.

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Create an Entity Record using "Xrm.WebApi.createRecord" in JS

    Hi Amer,

    This is caused because in your request you had the wrong field name, you need use the schema name of the lookup field followed by the bind annotation.

    How to fix getting “Undeclared Property Error” when using Lookups with Dynamics 365 Web API - Microsoft Dynamics 365 Community

    Go Settings > Customizations > Customize the System > Entities > select the entity you need > Fields to find the lookup field.

    pastedimage1640741970884v1.png

    If it still doesn't work, you can refer following link to append the entity name to the schema name:

    An undeclared property ‘new_bulkadjustment’ which only has property annotations in the payload but no property value was found in the payload. – Mohammed Hameed Hussain

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Create an Entity Record using "Xrm.WebApi.createRecord" in JS

    Hi Amer Azzam,

    "edm_donorid" is your logical name, right? If so, please change it to schema name to have a try.

    You could find it here:

    pastedimage1640740597883v1.png

    Reference:

    https://stackoverflow.com/questions/43970292/an-undeclared-property-when-trying-to-create-record-via-web-api

    https://msolenacrm.blog/2020/09/13/power-apps-portal-web-api-erroran-undeclared-property-which-only-has-property-annotations-in-the-payload-but-no-property-value-was-found-in-the-payload/

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
DAnny3211 Profile Picture

DAnny3211 134

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 132

#3
Abhilash Warrier Profile Picture

Abhilash Warrier 70 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans