Hi!
I have been struggling A LOT with this issue:-)
Problem is: I have made a new button with a JavaScript function using XrmSvcToolkit.retrieveMultiple function. I'm getting the rows I want but there is a Currency field there I can't read... it says "You must enter a number between -100000000... and 10000000...". Reading other fields is no problem, therefore I'm sure its the Currency field that causes me trouble.
Have also tried XrmSvcToolkit.fetch... same problem, can't get the value/sum. I know for sure the xml is OK.
Please help me, I'm stuck again:-)
RetrieveMultiple code:
function recalculateestimatedvalue(opportunityid) { var opportunityEV = Xrm.Page.getAttribute("estimatedvalue").getValue(); //alert("opportunityEV 1 : " + opportunityEV); opportunityEV = 0; var opportunityGuid = opportunityid.replace("{", "'").replace("}", "'"); var filterQuery = "?$filter=statecode/Value eq 0 and eeg_OpportunityId/Id eq guid" + opportunityGuid; XrmSvcToolkit.retrieveMultiple({ entityName: "eeg_produktlinje", async: false, odataQuery: filterQuery, successCallback: function (result) { for (i = 0; i < result.length; i++) { opportunityEV = opportunityEV + result[i].eeg_Sum.value; } //alert("opportunityEV 2 : " + opportunityEV); Xrm.Page.getAttribute("estimatedvalue").setValue(opportunityEV); }, errorCallback: function (error) { alert("Reculculating estimated value failed: " + error.description); } }); }
Fetch code:
function recalculateestimatedvalue(opportunityid) { //var opportunityGuid = opportunityid.replace("{", "'").replace("}", "'"); var fetchXml = "<fetch mapping='logical' distinct='false' aggregate='true'>"+ "<entity name='eeg_produktlinje'>"+ "<attribute name='eeg_sum' aggregate='sum' alias='evSum'/>"+ "<filter type='and' >"+ "<condition attribute='eeg_opportunityid' operator='eq' value='" + opportunityid + "'/>"+ "</filter>"+ "</entity>"+ "</fetch>"; var opportunityEV = Xrm.Page.getAttribute("estimatedvalue").getValue(); opportunityEV = 0; XrmSvcToolkit.fetch({ fetchXml: fetchXml, async: false, successCallback: function (result) { if (result != null) { Xrm.Page.getAttribute("estimatedvalue").setValue(result.evSum); } }, errorCallback: function (error) { alert("Reculculating estimated value failed: " + error.description); } }); }
BR Knut Myre