Hello, @all. How can I add lines to a sublist crea...
# suitescript
j
Hello, @all. How can I add lines to a sublist created with serverWidget? Thanks in advance! I encountered this error
{"type":"error.SuiteScriptError","name":"SSS_MISSING_REQD_ARGUMENT","message":"Sublist.setSublistValue: Missing a required argument: options.id","id":null,"stack":["Error"," at /SuiteScripts/extensions/sl_saved_search_result.js:75:33"," at Array.forEach (native)"," at /SuiteScripts/extensions/sl_saved_search_result.js:74:29"," at postFunction (/SuiteScripts/extensions/sl_saved_search_result.js:73:30)"," at Object.onRequest (/SuiteScripts/extensions/sl_saved_search_result.js:11:17)"],"cause":{"name":"SSS_MISSING_REQD_ARGUMENT","message":"Sublist.setSublistValue: Missing a required argument: options.id"},"notifyOff":false,"userFacing":true}
const form = serverWidget.createForm({
title: 'Saved Search Results' }); const savedSearch = search.load({ id: searchId }); const searchResult = savedSearch.run(); let sublist = form.addSublist({ id: 'custpage_results', type: serverWidget.SublistType.LIST, label: 'Search Results' }); const columns = searchResult.columns; columns.forEach(column => { sublist.addField({ id: column.name, type: serverWidget.FieldType.TEXT, label: column.label }); }); let lineCount = 0; searchResult.each(result => { columns.forEach(column => { sublist.setSublistValue({ sublistId: 'custpage_results', fieldId: column.name, line: lineCount, value: result.getValue(column) }); }); lineCount++; }); context.response.writePage(form);
e
See this doc.
LIST
is not what the type of sublist you want:
This type of sublist has a fixed number of lines. You can update an existing line, but you cannot add lines to it.
b
pay closer attention to the parameters of Sublist.setSublistValue
the list sublist type is fine for what you are doing, serverside is the only place you can add lines
client side on the browser is where you cant add lines
j
Thanks @erictgrubaugh, @battk
I solved the problem
This error related with value in setSublistValue