03/20/2018, 3:16 PM
If there are always two results and the first one is amount1 and second amount2 you could loop over results and put even indices in amount1 and odd indices in amount2. But you can never be too sure with Netsuite 🙂 so I would do it like this (pseudocodey, but change it to your choice of suitescript version).
Copy code
var accountDict = {};
results.forEach(function(res) {
    var accountId = res.account;
    var amount = res.amount;
    accountDict[accountId] = accountDict[accountId] || {account: accountId};
    var prop = accountDict[accountId].hasOwnProperty('amount1') ? 'amount2': 'amount1';
    accountDict[accountId][prop] = amount;