Tuesday, March 6, 2018

MSCRM JavaScript Create Record Using Xrm.WebApi Request

Source Code:


function createRecordUsingXrm() {
       var recordData =
             {
                    "new_name": "TestXrmWebApiRecord",
                   "new_projecttype": true,
                   "new_percentagecompleted": 100,
                   "new_projectdescription": "Test",
                   "new_budget": 1500.50,
                   "new_noofresources": 30,
                    "new_existingproducts": 1000000,
                    "new_projectduration": 12,
                    "new_account@odata.bind": "/accounts(2123455D-BE62-E411-80D6-B4B52F567EC8)"
         }

         parent.Xrm.WebApi.createRecord("new_myproject", recordData).then(
          function success(result) {
              Xrm.Utility.alertDialog("Record Created Successfully");
          },
          function (error) {
              console.log(error.message);
          });
}

No comments:

Post a Comment