RE: How to apply filter fields to Suitelet with Client Script

I’ve been building a Suitelet to display the result and columns dynamically from a saved search. Where I’m running into an issue is I need to be able to trigger an update to my sublist once the field has been set to update the filter on list. I’m ideally looking for something where I don’t have to trigger off of a button but if I need to I will.


Any help would be much appreciated.



* @NApiVersion 2.x

* @NScriptType Suitelet


define(['N/ui/serverWidget', 'N/search', 'N/runtime'], function(serverWidget, search, runtime) {

function suiteletList(context){
if (context.request.method === 'GET') {

var form = serverWidget.createForm({title: 'Transactions'});

var itemField = form.addField({ id: 'custpage_item' ,type: serverWidget.FieldType.SELECT, label: 'Item' ,source: 'item'});

var objSublist = form.addSublist({id: 'custpage_sublist1' ,type:serverWidget.SublistType.LIST ,label: 'sublist1'});

var objCurrScript = runtime.getCurrentScript();

var param_SavedSearchId = objCurrScript.getParameter({ name:'custscript_suitelet_search' });

var objSublistSearch = search.load({ id: param_SavedSearchId });


var fltrPFA = search.createFilter({ name:'item' ,operator:'IS' ,values: itemField });


var SublistSearch =;

var SublistSearchResults = SublistSearch.getRange(0, 1000);
var c = 0;



var colName = 'custpage_col' + c;

if (col.label != 'nodisplay') {

objSublist.addField({ id:colName ,label:col.label ,type: serverWidget.FieldType.TEXT });


for (var ix = 0; ix < SublistSearchResults.length; ix++) {

var result = SublistSearchResults[ix];

var c = 0;
//loop through the columns to fill the data

for (var k in result.columns) {


var colName = 'custpage_col' + c;
if (result.columns[k].label != 'nodisplay') {

var fieldValue;

if ( result.getText(result.columns[k]) ){

fieldValue = result.getText(result.columns[k])

} else {

fieldValue = result.getValue(result.columns[k])

if (!fieldValue) {

fieldValue = ' ';


//add the value to the row / column

objSublist.setSublistValue({ id:colName ,value:fieldValue ,line: ix });




form.getClientScriptModulePath = './cs_script_sublist_search.js';


return {

onRequest: suiteletList


rgardner091 Rookie Asked on October 25, 2020 in SuiteScript.
Add Comment
3 Answers

Attach a client script to your suitelet and use the fieldChanged function to redirect to the suitelet with different parameters.

use window.onbeforeunload = null;  – to get rid of the “changes may not get saved” message (or something like this)

Rookie Answered on October 27, 2020.
Add Comment

Your Answer

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