how do I get and set values from subsequent pages ...
# ask-stanley-ai
a
how do I get and set values from subsequent pages of a suitelet with paged results?
c
AI generated answer (using internal Slack threads):
To get and set values from subsequent pages of a suitelet with paged results, you can use a combination of SuiteScript and jQuery. Here's a general approach: 1. Storing Selected Values: You can add a hidden field to your suitelet form to store the selected values. Whenever a user selects or deselects a checkbox, update this hidden field with the current selection. This way, you can retain the user's selection even when they navigate to different pages. 2. Populating Checkbox Selections: When you move to a new page, you can populate the checkboxes based on the values stored in your hidden field. This will ensure that the user's previous selections are reflected correctly. 3. Handling Pagination with jQuery: You can use jQuery to hide or show lines based on the current page number. All the data is still there, but jQuery hides different groups based on the page number. Here's a sample code snippet that demonstrates this approach:
Copy code
javascript
//listens fieldChanged
function handlePageChange(rec, context) {
    var currPage = Number(rec.getValue(context.fieldId));
    var multiplier =100;
    var minRow = (currPage - 1) * multiplier;
    var maxRow = (currPage * multiplier) - 1;
    var lineCount = rec.getLineCount('custpage_sublistid');
    for (var i = 0; i < lineCount; i++) {
        (i >= minRow && i <= maxRow)
            ? updateRowDisplay(i, '')
            : updateRowDisplay(i, 'none');
    }
}

//listens handlePageChange
function updateRowDisplay(line, displayType) {
    jQuery('#custpage_sublistidrow' + line).css('display', displayType);
}
This code listens for a field change (which would be your page number), calculates the minimum and maximum row numbers for the current page, and then loops through all the lines in your sublist. If a line is within the current page, it is displayed; otherwise, it is hidden. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.833600044
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.826898754
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.824913383
Please provide your feedback on this answer.