Friday, 20 May 2016

Delete Record in in Microsoft Dynamics CRM 2016 using Web API


  function DeleteAccount() {
      //get Server url
        var serverURL = Xrm.Page.context.getClientUrl();

        //create Xml request object 
        var service = new XMLHttpRequest();

        //below line is used to delete the entity record  
        service.open("DELETE", serverURL + "/api/data/v8.0/accounts(1DD18913-11CB-E511-80D2-C4346BDC11C1)", false);
        service.setRequestHeader("Accept", "application/json");
        service.setRequestHeader("Content-Type", "application/json; charset=utf-8");
        service.setRequestHeader("OData-MaxVersion", "4.0");
        service.setRequestHeader("OData-Version", "4.0");
        service.send();

        if (service.readyState == 4 /* complete */) {
        if (service.status == 204) {
            //show alert message 
            alert('Field Value Deleted');
        }
        else {
            var error = JSON.parse(service.response).error;
            //show error message
            alert(error.message);
        }
    }      
}
 

No comments:

Post a Comment

Read only field , get latest value from read only field in in power app portal

Below line is used to make field readonly in power app portal through js $( "#bdo_relationshiprole_name" ).parent().css( "po...