Question

Below is my Product sub grid on Quote Entity.

Now On addition of new product , I am calculating Service tax and tax based on Price per unit, quantity and discount.

Now i need to set calculated service tax and tax value in sub grid.

enter image description here

I want to Update record of a Sub-grid in Quote Entity. I have tried below code, but still not able to update my sub grid .

function OnRefresh()
{ 
    var gridControl = document.getElementById("quotedetailsGrid").control;
    var  ids = gridControl.get_allRecordIds();  

    for (i = 0; i < ids.length; i++) {

      var quotedetail = new Object(); 
      quotedetail.new_service_tax = "1000";                 

      var id = ids[i].replace("{", "").replace("}", "");                                        

      QuoteProductRecord(id,quotedetail);

    }
}


function QuoteProductRecord(id,quotedetail) {

var jsonEntity = window.JSON.stringify(quotedetail);

var ODataPath = Xrm.Page.context.getServerUrl() + "/XrmServices/2011/OrganizationData.svc/QuoteDetailSet";

$.ajax({
    type: "POST",
    contentType: "application/json; charset=utf-8",
    datatype: "json",
    data: jsonEntity,
    url: ODataPath + "(guid'" + id + "')",
    beforeSend: function (XMLHttpRequest) {
        XMLHttpRequest.setRequestHeader("Accept", "application/json");
        XMLHttpRequest.setRequestHeader("X-HTTP-Method", "MERGE");
    },
    success: function (data, textStatus, XmlHttpRequest) {

       alert("Success");
    },
    error: function (XMLHttpRequest, textStatus, errorThrown) { }
});

}

Issue is that there is no error thrown, but still Service tax and tax value in sub grid is blank.

In JSON function, i have also tried to alert success message , but neither i got any success message nor any error message.

Was it helpful?

Solution 2

I have just import my solution with above code in my production environment (CRM2013 Online). and it worked fine.

OTHER TIPS

Check if the operations that you are doing are legit. Is it possible that you are passing a value that results in an empty string.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top