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,...
Suggested Answer

Unable to set lookup field value using Xrm.WebApi.online.createRecord

(0) ShareShare
ReportReport
Posted on by 15

I'm creating new record using Xrm.WebApi.online.createRecord. I'm adding lookup field value while creating record. See my code below. In the code, new_engagementsector is my lookup field name, 'new_sectors' is the name of lookup entity & 'cr0f8_engagements' is my entity name in which i am adding record.

var entity = {};
entity["new_engagementsector@odata.bind"] = "/new_sectors(97511775-8737-ea11-a813-000d3a0a827e)";

Xrm.WebApi.online.createRecord("cr0f8_engagements", entity).then(
function success(result) {
var newEntityId = result.id;
},
function(error) {
Xrm.Utility.alertDialog(error.message);
});

Its giving below error,

An error occurred while validating input parameters: Microsoft.OData.ODataException: An undeclared property 'new_engagementsector' which only has property annotations in the payload but no property value was found in the payload.

Is there anything missing in code? please help.

I have the same question (0)
  • Suggested answer
    Naveen Ganeshe Profile Picture
    3,397 User Group Leader on at

    Hello Vishal,

    Everything looks good but please make sure you are using the schema name for "new_engagementsector" field.

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

    Hello,

    You need to use schema name of the field instead of logical name.

    entity["SchemaNameofthefield@odata.bind"] = "/new_sectors(97511775-8737-ea11-a813-000d3a0a827e)";

    Please check below link.

    community.dynamics.com/.../create-record-of-custom-entity-through-web-api

  • cloflyMao Profile Picture
    25,210 on at

    Hi,

    To update a lookup field, you should use field schema name.

    You can find schema name property in entity > fields.

    pastedimage1579158137931v1.png

    In most of cases, it will contains some upper case characters.

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 70 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 33 Most Valuable Professional

#3
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans