Call Dynamics 365 Web API Using JavaScript - Using Xrm.WebApi

Create a record for custom entity record by calling Web API

var Gender;
var Indian;
var Technologies = "";

function CreatePerson() {
    var data =
    {
        "new_firstname": document.getElementById("firstName").value,
        "new_lastname": document.getElementById("lasttName").value,
        "new_dob": document.getElementById("DOB").value,
        "new_age": document.getElementById("Age").value,
        "new_gender": Gender,
        "new_indian": Indian,
        "new_salary": parseInt(document.getElementById("Salary").value),
        "new_technology": Technologies
    }

    debugger;

    Xrm.WebApi.createRecord("new_person", data).then(
        function success(result) {
            alert("Peron created with id: " + result.id);
        },
        function (error) {
            alert("Error in API: " + error.message);
        }
    );
}

Comments

Popular posts from this blog

Call Dynamics 365 Web API Using JavaScript - Using XMLHttpRequest

Dynamics 365: Call global action with input and output parameters through JavaScript using XMLHttpRequest

Create related entity records along with the primary record in D365 using Web API Javascript - XMLHttpRequest