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

The normal flow for a suitelet is a GET to the suitelet which generates the initial form. You can then use a submit button which does a form POST which allows you to get the parameters set on the form. For your case, you could use the submit button to get the value of your item field and then write a new form.

If that is too unwieldy for you, then you can use a client script to get the value of the item field and then manipulate the sublist using the methods available on a currentRecord. This tends to be too slow for large numbers of sublist rows, it mimics the functionality of the ui too closely to be fast.

Advanced Answered on October 26, 2020.

Hello Battik,

I am doing what you stated, I have fieldchanged event and then filed the sublist but I do not see the sublist getting an update


Here is my Suitelet sublist:

sublist = formobj.addSublist({
id: ‘custpage_item_assembly’,
type: ui.SublistType.LIST,
label: ‘Assembly Item’,
tab: ‘custpage_main_tab’

Client script code:

var counter= nlapiGetLineItemCount(“custpage_sublist_item”)+1;
nlapiSetLineItemValue(“custpage_sublist_item”, “sublist1”, counter, internalid);
nlapiSetLineItemValue(“custpage_sublist_item”, “sublist2”,counter, itemid);



on December 25, 2021.
Add Comment

Your Answer

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