How to create a record in Dynamics 365 Online V 9.X using JavaScript WebAPI?

Below is the latest Syntax available to create a record in Dynamics 365 Online V9.X using JavaScript,


Xrm.WebApi.createRecord(entityLogicalName, data).then(successCallback, errorCallback);


Name Type Required Description
entityLogicalName String Yes Logical name of the entity you want to create. For example: “account”.
data Object Yes A JSON object defining the attributes and values for the new entity record.

See examples later in this topic to see how you can define the data object for various create scenarios.

successCallback Function No A function to call when a record is created. An object with the following properties will be passed to identify the new record:

·        entityType: String. The entity logical name of the new record.

·        id: String. GUID of the new record.

errorCallback Function No A function to call when the operation fails. An object with the following properties will be passed:

·        errorCode: Number. The error code.

·        message: String. An error message describing the issue.

Return Value:
On success, returns a promise object containing the attributes specified earlier in the description of the successCallback parameter.

Create a new Javascript Webresource (new_Account.js) and copy paste the below code in it and call it OnLoad of the page of the Account.

After that, open any existing Account record

function CreateAccountRecord() {
 // Define the data to create new account
 var accountData =
 "name": "Arun Potti Inc.", // Single Line of Text
 "creditonhold": false, // Two Option Set
 "description": "This is the description of the sample account", // Multiple Lines of Text
 "revenue": 10000000, // Currency
 "industrycode": 1, // 1 - Accounting // OptionSet
 "primarycontactid@odata.bind": "/contacts(39582A13-E6E7-E711-A95E-000D3AF27CC8)" // ContactId - Arun Potti // Lookup

// Create account record
 Xrm.WebApi.createRecord("account", accountData).then(
 function success(result) {
 // Show Account GUID
 Xrm.Utility.alertDialog("Account created with ID: " +, null);
 function (error) {
 // Show Error
 Xrm.Utility.alertDialog("Error :" + error.message, null);


Dynamics 365 Record Creation V9.X

Hope you have successfully created a record using New Syntax.

How to Setup Dynamics 365 30 days Online Trial version?

Follow the below steps to Setup Dynamics 365 30 days Trial Version.

Step 1: Click here and open Dynamics 365 Trials. Click on Sign up here.

CRM Trials

Click on No, continue signing up.

Dynamics 365 Signup

Step 2: Give your Personal Information and click on Next.

Dynamics CRM 365 - Setup 1

Step 3: Create User Id and Password to login CRM 365 Trial. Click on Create my account.

Dynamics CRM 365 - Setup 2

Step 4: Select the Country Code and give your mobile number for verification. Click on Text me.

Dynamics CRM 365 - Setup 3

Step 5: Enter the OTP and click on Next.

Dynamics CRM 365 - Setup 4

Step 6: Please allow system for some time, a Trial Version will be created for your account. You can see the progress.

Dynamics CRM 365 - Setup 5Click on Set up.

Dynamics CRM 365 - Setup 6

Step 7: Select the required scenarios fits you best.

Am selecting None of these. Don’t customize my organization and click on Complete Setup.

Dynamics CRM 365 - Setup 7

Step 8: CRM Trial Organization will be ready with the selected scenarios/ none in few minutes.

Dynamics CRM 365 - Setup 8

Step 9: After Set up done, System will navigate to the CRM Trial Organization.

Dynamics CRM 365 - Setup 9

Step 10: As we see we don’t have any sample data on CRM Trial. Click here for my previous post and install Sample data in CRM.

Hope you successfully created CRM Trial and Installed Sample Data in CRM.

Enjoy by exploring CRM :):):)