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 :
Microsoft Dynamics CRM (Archived)

XRM.WebApi Create a contact anche update field parentcustomerid ERROR, please Help

(0) ShareShare
ReportReport
Posted on by 327

Hello every body I receive this error 

"error.message "An undeclared property 'parentcustomerid' 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.""

This is the JS code that return the error

var data3 =
       {
        "parentcustomerid@odata.bind": "/accounts("+ accountId.toString().replace("{","").replace("}","") +")"
       }
       
       Xrm.WebApi.updateRecord("contacts", result.id.toString().replace("{","").replace("}",""), data3).then(
        function success(result) {
         console.log("Contact updated");
         formContext.data.refresh(true).then( CG.CapApi.Utils.successCallback,CG.CapApi.Utils.errorCallback);
         
        },
        function (error) {
         console.log(error.message);
         
        }
       );

All code 

WebApiDemo: function (executionContext) {
 
     var formContext = executionContext.getFormContext();
  var accountName = formContext.getAttribute("name").getValue();
  var accountId = formContext.data.entity.getId();
  
  Xrm.WebApi.retrieveMultipleRecords("contact", "?$select=contactid&$filter=contains(fullname,'"+accountName+"')").then(
   function success(result)
   {
    if(result.entities.length == 0)
    {
     var data =
     {
       "firstname": accountName,
       "lastname" : "Test"
       //"parentcustomerid@odata.bind": "/accounts("+accountId.toString().replace("{","").replace("}","")+")"
     }
     
     Xrm.WebApi.createRecord("contact", data).then(
      function success(result) {
       console.log("Contact created with ID: " + result.id);
       
       /* var data2 =
       {
        "primarycontactid@odata.bind": "/contacts("+ result.id.toString().replace("{","").replace("}","") +")"
       }
       
       Xrm.WebApi.updateRecord("account", accountId.toString().replace("{","").replace("}",""), data2).then(
        function success(result) {
         console.log("Account updated");
         formContext.data.refresh(true).then( CG.CapApi.Utils.successCallback,CG.CapApi.Utils.errorCallback);
         
        },
        function (error) {
         console.log(error.message);
         
        }
       );  */
       var data3 =
       {
        "parentcustomerid@odata.bind": "/accounts("+ accountId.toString().replace("{","").replace("}","") +")"
       }
       
       Xrm.WebApi.updateRecord("contacts", result.id.toString().replace("{","").replace("}",""), data3).then(
        function success(result) {
         console.log("Contact updated");
         formContext.data.refresh(true).then( CG.CapApi.Utils.successCallback,CG.CapApi.Utils.errorCallback);
         
        },
        function (error) {
         console.log(error.message);
         
        }
       );
      },
      function (error) {
       alert(error.message);
      }
     );     
    }
    else
    {
      alert("Already exist a contact containg this name");
    }
   },
   function (error) {
     console.log(error.message);
     
   }
  );
    },

    successCallback :function()
 {
  
  
 },

 errorCallback :function()
 {
  
  
 }

Please Help me 

Best regards

 

 

 

 

*This post is locked for comments

I have the same question (0)
  • Rawish Kumar Profile Picture
    13,758 on at
    RE: XRM.WebApi Create a contact anche update field parentcustomerid ERROR, please Help

    Hi There,

    make sure you are using the schema name if the lookup & not the logical name.

    for e.g ParentCustomerId not parentcustomerid.

    you can check the schema from your customization or solution. Navigate to Entiies > fields> refer to schema name column.

    mark my suggestion as verified if helpful to close the thread and help others.

  • Gmanunta81 Profile Picture
    327 on at
    RE: XRM.WebApi Create a contact anche update field parentcustomerid ERROR, please Help

    Hello Rawish Kumar.

    I does not work.

    I Tried this code (ParentCustomerId instead of parentcustomerid):

    "ParentCustomerId@odata.bind": "/accounts("+ accountId.toString().replace("{","").replace("}","") +")"

    the parentcustomerid is a particular (Standard)field of contact entity. The field type is Customer type.

    any other suggestion(May be I forget somethig or I do some mistake)  ?

  • Rawish Kumar Profile Picture
    13,758 on at
    RE: XRM.WebApi Create a contact anche update field parentcustomerid ERROR, please Help

    Hello,

    did you also change primarycontactid to PrimaryContactId

  • Gmanunta81 Profile Picture
    327 on at
    RE: XRM.WebApi Create a contact anche update field parentcustomerid ERROR, please Help

    Yes, it does not work

  • Mahendar Pal Profile Picture
    45,095 on at
    RE: XRM.WebApi Create a contact anche update field parentcustomerid ERROR, please Help

    Hello,

    You need to write contact instead of contats in updateRecord method

    var data3 =

          {

           "parentcustomerid@odata.bind": "/accounts("+ accountId.toString().replace("{","").replace("}","") +")"

          }

          Xrm.WebApi.updateRecord("contacts", result.id.toString().replace("{","").replace("}",""), data3).then(

           function success(result) {

            console.log("Contact updated");

            formContext.data.refresh(true).then( CG.CapApi.Utils.successCallback,CG.CapApi.Utils.errorCallback);

           },

           function (error) {

            console.log(error.message);

           }

          );

    Also make sure account GUID is formatting correctly.

  • Aric Levin - MVP Profile Picture
    30,190 Moderator on at
    RE: XRM.WebApi Create a contact anche update field parentcustomerid ERROR, please Help

    I see the same as Mahen. Contacts is showing as plural instead of singular (contact).

    Try this one out.

  • Gmanunta81 Profile Picture
    327 on at
    RE: XRM.WebApi Create a contact anche update field parentcustomerid ERROR, please Help

    Hello guys,

    It does not work

    Error message

    message "An undeclared property 'parentcustomerid' 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."

    Code rows related

    var data3 =

    {

    "parentcustomerid@odata.bind": "/accounts("+ accountId.toString().replace("{","").replace("}","") +")"

    }

    Xrm.WebApi.updateRecord("contact", result.id.toString().replace("{","").replace("}",""), data3).then(

    function success(result) {

          console.log("Contact updated");

    formContext.data.refresh(true).then( CG.CapApi.Utils.successCallback,CG.CapApi.Utils.errorCallback);

    },

    function (error) {

    console.log(error.message);

    }

    );  

  • Rawish Kumar Profile Picture
    13,758 on at
    RE: XRM.WebApi Create a contact anche update field parentcustomerid ERROR, please Help

    again i can see you did not changed the below :

    parentcustomerid@odata.bind": "/accounts("+ accountId.toString().replace("{","").replace("}","") +")"

    user ParentCustomerId instead of above.

  • Gmanunta81 Profile Picture
    327 on at
    RE: XRM.WebApi Create a contact anche update field parentcustomerid ERROR, please Help

    This code does not work. I used the "ParentCustomerId" field please see the code below

    var data3 =

    {

    //"primarycontactid@odata.bind": "/contacts("+ result.id.toString().replace("{","").replace("}","") +")"

     "ParentCustomerId@odata.bind": "/accounts("+ accountId.toString().replace("{","").replace("}","") +")"

    }

    Xrm.WebApi.updateRecord("contact", result.id.toString().replace("{","").replace("}",""), data3).then(

    function success(result) {

    console.log("Contact updated");

    formContext.data.refresh(true).then( CG.CapApi.Utils.successCallback,CG.CapApi.Utils.errorCallback);

    },

    function (error) {

    console.log(error.message);

    }

    );  

    The error returned is

    error.message "An undeclared property 'ParentCustomerId' 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 Help.

  • Verified answer
    Gmanunta81 Profile Picture
    327 on at
    RE: XRM.WebApi Create a contact anche update field parentcustomerid ERROR, please Help

    I solved the Issue in this way

    var accountdata = "/accounts("+ accountId.toString().replace("{","").replace("}","") +")"

    var data3 =

    {

    //"primarycontactid@odata.bind": "/contacts("+ result.id.toString().replace("{","").replace("}","") +")"

     "parentcustomerid_account@odata.bind": accountdata

    }

    Xrm.WebApi.updateRecord("contact", result.id.toString().replace("{","").replace("}",""), data3).then(

    function success(result) {

    console.log("Contact updated");

    formContext.data.refresh(true).then( CG.CapApi.Utils.successCallback,CG.CapApi.Utils.errorCallback);

    },

    function (error) {

    console.log(error.message);

    }

    );  

    please use the field name "parentcustomerid_account" on odata request

    please see the solution by Andrew Butenko

    Thanks Butenko !!!!!

    https://community.dynamics.com/crm/f/117/t/230854

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

#3
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans