TIL: To be able to have a functioning `STATICLIST`...
# suitescript
w
TIL: To be able to have a functioning
STATICLIST
on a record. • The UE-script needs to allow the CLIENT-context to make paging and sorting work. • The UE-script needs to handle the request parameters for sorting and handle the sorting before adding the lines to the sub-list. (Feel Free to correct me on this)
Copy code
let sublistColumnsValues = [
        [
            { id: 'custpage_column_1', value: '1' },
            { id: 'custpage_column_2', value: 'z' },
        ],[
            { id: 'custpage_column_1', value: '2' },
            { id: 'custpage_column_2', value: 'y' },
        ],[
            { id: 'custpage_column_1', value: '3' },
            { id: 'custpage_column_2', value: 'x' },
        ]
    ]

    const sortField = request.parameters.si_custpage_attachments_sublistsortfld
    const sortDirection = request.parameters.si_custpage_attachments_sublistsortdir

    if(sortField && sublistColumnsValues.length > 0) {
        const columnIndex = sublistColumnsValues[0].findIndex(column => <http://column.id|column.id> === sortField)
        sublistColumnsValues = sublistColumnsValues.sort((a, b) => {
            if(sortDirection === 'UP') {
                return a[columnIndex].value.localeCompare(b[columnIndex].value)
            }
            return b[columnIndex].value.localeCompare(a[columnIndex].value)
        })
    }