RE: Is it possible to load a saved search in script and change the column that it is sorted by?

I use a saved search for a Suitelet and want to get around the limitation that the native column sort ONLY sorts the data on the current page. Instead, my client wants the entire dataset re-sorted.

I can get the columns off the search object after I load the search, and I try to overwrite the search.columns[i].sort element with “DESC” and set the default column to “NONE” but the results are not showing the data sorted.

Unfortunately, I think I need to create a NEW scripted search… which is a pain in the behind but not the worst. Anyone ever figure out how to change the sort direction of an existing saved search in script??

Scripting in 2.0 ~~~ any/all help helps!


var searchA = search.load({ id : 1430});

var columns = searchA .columns;

columns[1].sort = "NONE";

columns[8].sort = "DESC";

vfalk Beginner Asked on October 1, 2019 in SuiteScript.

The sort property might be read-only. It’s not actually documented as a property on the Column object, and with some quick testing in the console I was unable to change the sort order. I was essentially trying the same approach as you, using the search.Sort enum values instead.

on October 1, 2019.
Add Comment
2 Answers

https://system.na0.netsuite.com/app/help/helpcenter.nl?fid=section_456142211913.html

After you create a column, you cannot change the sort order of the column. If you use the same column in another search and specify a new sort order, the previous sort order is still used.

Make a new columnn to replace the one you want to change

Advanced Answered on October 1, 2019.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.