Is there an easy way to combine two search result ...
# suitescript
k
Is there an easy way to combine two search result objects from different searches with the same columns and de-dup them?
l
The way I see it is you would need to create a JSON object and you add values to that object and detect duplicates at the same time as you iterate through search results.
p
I would use the _.uniq after converting the searches to a JSON object and combining them.
k
Copy code
var upcResult = search.load({
            id: 'customsearch_transaction_item_upc_diff'
        }).run().getRange({ start: 0, end: 5 });
        var nameResult = search.load({
            id: 'customsearch_transaction_item_name_diff'
        }).run().getRange({ start: 0, end: 5 });
        return upcResult.concat(nameResult).filter(function (value, pos, arr) { return arr.indexOf(value) === pos; });
👍 1
That's the solution I ended up with
Worked perfectly 🙂
limit of 1000 results per search though, so that's a bummer