Discussions
Stay up-to-date with the latest news from NetSuite. You’ll be in the know about how to connect with peers and take your business to new heights at our virtual, in-person, on demand events, and much more.
New AI Community Guidelines. Please review and follow them to ensure AI use stays safe, accurate, and compliant.
Using Sum with nlapiSearchRecord
How can I use SUM instead of calculating the total myself.
function xTotalGiving() { var CombinedTotal = 0; var filters = new Array(); filters[0] = new nlobjSearchFilter('entity', null,'is', nlapiGetRecordId()); filters[1] = new nlobjSearchFilter('posting', null,'is', 'T'); filters[2] = new nlobjSearchFilter('mainline', null,'is', 'T'); var columns = new Array(); columns[0] = new nlobjSearchColumn('totalamount', null, null); var searchresults = nlapiSearchRecord('transaction', null, filters, columns); for (var i = 0; searchresults != null && i &lt; searchresults.length; i++) { var searchresult = searchresults[i]; var totalamount = searchresult.getValue('totalamount'); <strong><span style="color:'"Red"'">CombinedTotal = Math.abs(totalamount) + Math.abs(CombinedTotal);</span></strong> } nlapiSetFieldValue('custentity_total_given_to_date',<strong><span style="color:'"Red"'">CombinedTotal</span></strong>); } 0