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

Javascript to sum Qty field

$
0
0

Hello all, is there a way to sum values using javascript?

There is a custom Batch Number which can have products. The same product can be in different Batch, but the code below is only getting the latest Qty value, I need to sum them.

Data sample:

Product Number - 12KDEK3DK

Batch Number: 5678 (Qty count of 12)

Batch Number: 9038 (Qty count of 3)

Total count is 15, but is only getting 12 since thats the latest record updated.

 
var entity = {};
entity.quantity = quantity ;

var req = new XMLHttpRequest();
req.open("PATCH", Xrm.Page.context.getClientUrl() + "/api/data/v8.0/salesorderdetails("12DA234K3J23")", true);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function () {
    if (this.readyState === 4) {
        req.onreadystatechange = null;
        if (this.status === 204) {
            //Success - No Return Data - Do Something
        }
        else {
            alert('Sales Order Product ' + this.statusText);
        }
    }
};
req.send(JSON.stringify(entity));


}






Viewing all articles
Browse latest Browse all 46379

Trending Articles



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