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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Create a new record and populate a lookup field using js

(0) ShareShare
ReportReport
Posted on by 2 User Group Leader

Hi, 
I get an error when trying to run the js code below. The idea is to create a new record and populate 3 fields on create. It seems to run fine when i remove the lookup field, but when adding that, then I get the following error: 

An error occurred while validating input parameters: Microsoft.OData.ODataException: Does not support untyped value in non-open type.

This is the code i try to run: 

function createContractFlowRecord(contractType) {

//Get Account GUID
var accountid = Xrm.Page.data.entity.getId();

//Get field "name" from Account entity
var accountName = Xrm.Page.getAttribute("name").getValue();
console.log(accountName);
console.log(accountid);

var entityLogicalName = "linak_contractflow";
var data = {
"linak_Account@odata.bind": "/Account(0e924ec4-3a3c-ea11-a812-000d3a4aa4e2)",
"linak_Contracttype": contractType,
"linak_name": "Test vit"

};

// create contract flow record
Xrm.WebApi.createRecord("linak_contractflow", data).then(
function success(result) {
console.log("Contract flow record created with ID: " + result.id);
// perform operations on record creation
},
function (error) {
console.log(error.message);
// handle error conditions
}
);
}

Can you see what I should be doing differently? I am testing it against D365 CE 9.1.0000.15051

BR, Vivian

I have the same question (0)
  • Verified answer
    Marco.P Profile Picture
    2,405 on at

    Hi,

    Try with

    linak_Account@odata.bind": "/accounts

  • Verified answer
    Miguel Lourenco Profile Picture
    Microsoft Employee on at

    Hi,

    I believe Marco is correct.

    However, next time use CrmRestBuilder ( https://github.com/jlattimer/CRMRESTBuilder), this will help you to automatically create the requests based on what you want.

  • Suggested answer
    Vivian Voss Profile Picture
    2 User Group Leader on at

    Hi Marco and Miguel,

    Thank you for your responses. Will definitely try that tool next time, thanks :)

    I finally managed to figure it out and it seems to be a combination of things:

    * it should be  accounts instead of account, yes

    * linak_Contracttype field should not be with at capital C

    Br, Vivian

  • r_m_w Profile Picture
    15 on at

    Does adding an s apply to all entities - specifically custom entities?

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 184 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 125

#3
CU11031447-0 Profile Picture

CU11031447-0 100

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans