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

Notifications

Announcements

No record found.

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)
  • Suggested answer
    Hicham GRC Profile Picture
    200 on at

    Hi Amer, 

    Can you try this way : 

    var data = { "edm_donorid@odata.bind": "/contacts("   result["_edm_donorid_value"]   ")" }

    You'll find here examples of how you pass lookup params : https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/xrm-webapi/createrecord

    KR,

    Hicham

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    Hi,

    Format of lookup is incorrect.

    Please try with below format -

    entity["edm_donorid@odata.bind" = "/contacts(result["_edm_donorid_value")";

    var entity = {};
    entity["msft_emergencycontact@odata.bind"] = "/contacts(12334)";
    
    Xrm.WebApi.online.createRecord("msft_employee", entity).then(
        function success(result) {
            var newEntityId = result.id;
        },
        function(error) {
            Xrm.Utility.alertDialog(error.message);
        }
    );

    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

    Hi Amer,

    For the error -"Does not support untyped value in non-open type", you can refer following links for more details:

    What is “Does not support untyped value in non-open type” ODataException in creating records in D365 CE? | D365 Demystified

    Dynamics CRM 365 WEB API Common Errors and Resolution – xrm CRM Dynamics (wordpress.com)

    And I think this suggestion mentioned in the article is desirable -- avoiding this error is to use Rest Builder tool to generate API code.

    pastedimage1640654181831v1.png

    pastedimage1640654989540v2.png

  • Suggested answer
    Hicham GRC Profile Picture
    200 on at

    Hi Amer,

    Please verify the field name.

    Also, as mentionned by Leah you can use Rest builder tool, it will generate the code for you.

    Hicham

  • Amer Azzam Profile Picture
    97 on at

    Hi all,

    Thanks for your reply all, but I faced another error when I used the below solution.

    var data =
                           {
                               "edm_donorid@odata.bind": "/contacts("   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
                                }
                            );

    "Microsoft.OData.ODataException An undeclared property 'edm_donorid' 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."

  • Amer Azzam Profile Picture
    97 on at

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

    "Microsoft.OData.ODataException An undeclared property 'edm_donorid' 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."

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

            var data =
              {
                "edm_donorid@odata.bind": "/contacts("   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
                     }
                      );

  • Suggested answer
    Community Member Profile Picture
    on at
  • Suggested answer
    Community Member Profile Picture
    on at

    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
    Bipin D365 Profile Picture
    28,983 Moderator on at

    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/

  • Amer Azzam Profile Picture
    97 on at

    hello Steve,

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

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 170 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 70

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans