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.

  • cloflyMao Profile Picture
    25,208 on at
    RE: Unable to set lookup field value using Xrm.WebApi.online.createRecord

    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.

  • Suggested answer
    Bipin D365 Profile Picture
    28,981 Moderator on at
    RE: Unable to set lookup field value using Xrm.WebApi.online.createRecord

    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

  • Suggested answer
    Naveen Ganeshe Profile Picture
    3,393 User Group Leader on at
    RE: Unable to set lookup field value using Xrm.WebApi.online.createRecord

    Hello Vishal,

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

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 225 Super User 2025 Season 1

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 106

#3
Vahid Ghafarpour Profile Picture

Vahid Ghafarpour 82 Super User 2025 Season 1

Overall leaderboard

Product updates

Dynamics 365 release plans