To create a record in Dynamics with Xrm.WebApi the syntax below can be used. In the example below we create an account record with multiple fields about the account and a reference to a primary contact of the account.
let data = {
"name": "Litware Publishing",
"description": "An example account created with Xrm WebApi.",
"telephone1": "+09-70-01-90-90",
"address1_line1": "39, quai du Roosevelt",
"address1_city": "Paris",
"address1_postalcode": "address1_postalcode",
"address1_country": "France",
"primarycontactid@odata.bind": "/contacts(53a0e5b9-88df-e311-b8e5-6c3be5a8b200)",
}
// Create account record
await Xrm.WebApi.createRecord("account", data).then(
function success(result) {
console.log("Account created with ID: " + result.id);
},
function (error) {
console.log(error.message);
}
);
In the image below it show how it looks when running the script in the developer console in the browser.
Image of how the script looks when creating an account record in Dynamics 365 with a primary contact.
The Two Option Set field in Dynamics 365 is a common way for users to represent boolean values like Yes/No or True/False. By default, the field appears as a drop-down list with two options or a toggle button. However, to improve user experience, it is possible to customize the field to display as checkboxes instead. This option can be especially helpful in certain scenarios, allowing for more streamlined data entry and a more user-friendly interface.