RE: How to get Sequencewise amount from saved search?
I have created saved search to get total amount of net pay, total amount of tax deduction, etc. I used group and sum in saved search. Now I am getting result as:
getSequence 104
getAmounts 5213.89
getSequence 100
getAmounts 2564.21
sequence means–100 for net pay, 104 for tax
How to get result as, sequence 100 amount 2564.21, sequence 104 amount 5213.89, in suitescript? Please help someone!
Below is my code:
seems like you want to sort the results by low sequence first…
if you want to sort the results by SEQUENCE, then you should sort by SEQUENCE instead of sorting by AMOUNT (sort: search.Sort.ASC)
in my simulation, you should have retrieved AMOUNT2564.21 and SEQUENCE100 as the first data because you sorted the result by ASCENDING AMOUNT (this should translate to dealing with lowest amounts first)
… … …
here is a way to sort an ARRAY of OBJECTS by OBJECT property/attribute:
var employeeAmountTotals = [{amounts:5213.89, sequence:104}, {amounts:2564.21, sequence:100}]
//sort by sequence
employeeAmountTotals = employeeAmountTotals.sort(function(a, b){
return Number(a.sequence) – Number(b.sequence)
})
console.log(“employeeAmountTotals after sorting”, employeeAmountTotals);
for(var i=0;i<employeeAmountTotals.length;i++)
{
var getSequence=employeeAmountTotals[i].sequence;
var getAmounts=employeeAmountTotals[i].amounts;
console.log(“getSequence”,getSequence);
console.log(“getAmounts”,getAmounts);
}