Creating a record from JavaScript using the Xrm.WebAPi in Dynamics 365 V9

Create Record:

Let’s see how we can create a “Lead” record using newly introduced
 Web API calls in Dynamics 365 V9
Xrm.WebApi.createRecord(“entityLogicalName”,data).then(successCallback,errorCallback);
// This line of code is required if you are creating from HTML webresource.

<script src="ClientGlobalContext.js.aspx" type="text/javascript"></script>

var entityData =


                {
                    "subject": “leadFromWebApi”,
                    "lastname": “Ram”
                }


Xrm.WebApi.createRecord("lead", entityData).then(
                    function success(result)
                    {
                        alert("Record Created successfully and Id is: " + result.id);
                        console.log("Account created with ID: " + result.id);
                    },
                    function (error)
                    {
                        console.log(error.message);       
                    });



0 comments:

Post a Comment

Popular Posts