Posts

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

Image
1. I have created below action in dynamics 365. 2. new_CreatePerson action will create a new record for custom entity. 3. 4. Below is the JavaScript code to call the action. var   firstName ; var   lastName ; function   CreatePerson () {      debugger ;      firstName  =  document . getElementById ( "firstName" ). value ;      lastName  =  document . getElementById ( "lasttName" ). value ;      var   data  =     {          "new_name" :   firstName  +  " "  +  lastName ,          "new_firstname" :   document . getElementById ( "firstName" ). value ,          "new_lastname" :   document . getElementById ( "lasttName" ). value     }      debugger ;      var   req  =  new   XMLHttpRequest ();      req . open ( "POST" ,  Xrm . Page . context . getClientUrl () +  "/api/data/v9.1/new_CreatePerson" ,  true );      req . setRequestHeader ( "O

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

You have Person and Person Address custom entity. you wanted to call web API to create records for person and person address. You have added required web resources in CRM. var Gender; var Indian; var Technologies = ""; var firstName; var lastName; function CreatePerson() {     firstName = document.getElementById("firstName").value;     lastName = document.getElementById("lastName").value;     var data =     {         "new_name": firstName + " " + lastName,         "new_firstname": document.getElementById("firstName").value,         "new_lastname": document.getElementById("lastName").value,         "new_dob": document.getElementById("DOB").value,         "new_age": document.getElementById("Age").value,         "new_gender": Gender,         "new_indian": Indian,         "new_salary": parseInt(document.getElemen

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 i

Call Dynamics 365 Web API Using JavaScript - Using XMLHttpRequest

Image
Requirement is to create record for custom entity using dynamics 365 CRM Web API. 1. I have created one custom entity i.e. Person Entity.     Display Name is "Person"     Logical Name is "new_person"     Entity Name is "new_persons" in "ODataV4Metadata.xml" 2. Once you have created any custom entity, You have to download ODataV4Metadata.xml file from Developer resources. Open ODataV4Metadata.xml and search for your entity name. 3. Custom entity is as below. Entity has some custom attributes such as new_firstname new_lastname new_dob new_age new_gender new_indian new_salary new_technology 4. I have included two web resource files in solution. CreatePersonXhtml.html => This file renders html markup in dynamics 365 form. CreatePersonXhtml.js => To call the Web API. 5. You can include above web resource in any custom or system form as per your requirement. 6. CreatePersonXhtml.html as below <html lang="