// Assuming N/search is imported as `s` var mySalesOrderSearch = s.create({ type: 'salesorder' // Use the summary property of a Column to perform grouping/summarizing columns: [{ name: 'salesrep', summary: s.Summary.GROUP },{ name: 'internalid', summary: s.Summary.COUNT }], filters: [{ name: 'mainline', operator: 'is', values: ['T'] }] }); mySalesOrderSearch.run().each(function (result) { var repId = result.getValue({ "name": "salesrep", "summary": s.Summary.GROUP }); var repName = result.getText({ "name": "salesrep", "summary": s.Summary.GROUP }); var orderCount = parseInt(result.getValue({ "name": "internalid", "summary": s.Summary.COUNT }), 10); log.debug({ "title": "Order Count by Sales Rep", "details": repName + " has sold " + orderCount + " orders." }); return true; });
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter