Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 79901

Calculate the sum of amount field using oData

$
0
0
Hi,

We have a requirement by adding all the amount fields in the subgrid the sum of the amount should be equal or less than that of the amount field present in the tab in case screen. I used oData to fetch the values. how can we do the calculation?


function testSubGrid() { try { debugger; alert("testSubGrid"); var amountNum; if(Xrm.Page.getAttribute("new_amount").getValue()!=null) { amountNum = Xrm.Page.getAttribute("new_amount").getValue(); } alert(amountNum); if(amountNum!=null) { var serverUrl = Xrm.Page.context.getClientUrl(); alert(serverUrl); var guid1=Xrm.Page.data.entity.getId(); alert(guid1); var oDataPath =serverUrl+"/XRMServices/2011/OrganizationData.svc/new_fundtransferSet?$select=new_targetamount&$filter=new_case/Id eq guid'"+guid1+"'"; alert(oDataPath); var retrieveRecordsReq = new XMLHttpRequest(); retrieveRecordsReq.open("GET", oDataPath, true); retrieveRecordsReq.setRequestHeader("Accept", "application/json"); retrieveRecordsReq.setRequestHeader("Content-Type", "application/json; charset=utf-8"); alert(1); retrieveRecordsReq.onreadystatechange = function () { if (this.readyState == 4) { retrieveRecordsReq.onreadystatechange = null; alert(2); if (this.status == 200) { alert(3); var retrievedRecords = JSON.parse(retrieveRecordsReq.responseText).d; if (retrievedRecords.results.length > 0) { alert(4); //for(var i=0; i< retrievedRecords.results.length; i++) //{ //var cash=retrievedRecords.results[0].ccs_targetamount.Value; //alert("cash"+ cash); //} } } } }; retrieveRecordsReq.send(); } } catch(ex) { alert("Exception from testSubGrid " + ex.message); } }


 


Viewing all articles
Browse latest Browse all 79901

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>