dennysutanto
12/19/2024, 11:17 AMCeligo AI
12/19/2024, 11:17 AMAI generated answer (using internal Slack threads):To set the default sorting on a specific column on a sublist created in a Suitelet, you need to sort your data before adding it to the sublist. The sublist will default to the order you add the rows in SuiteScript. Here's a simple example of how you might do this:
javascript
// Assuming you have an array of objects representing your data
var data = [
{date: '2021-01-01', value: 'A'},
{date: '2021-02-01', value: 'B'},
{date: '2021-01-15', value: 'C'}
];
// Sort the data by date
data.sort(function(a, b){
return new Date(a.date) - new Date(b.date);
});
// Then add the sorted data to your sublist
for (var i = 0; i < data.length; i++) {
sublist.setSublistValue({
id: 'date',
line: i,
value: data[i].date
});
sublist.setSublistValue({
id: 'value',
line: i,
value: data[i].value
});
}
Please note that the sort arrow in the UI will always appear on the last column, regardless of the actual sort order of the data. This is a limitation of Suitelets and can be confusing for end users.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
12/19/2024, 11:17 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.879720926
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.866454601
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.854095
Celigo AI
12/19/2024, 11:17 AM