How to set Sublist line item value using client script in Netsuite SuiteScript 2.x
Anurag Kumar
1 min read
In This post we will learn how to set sublist field value in client script. We will write a code snippet in client script which will trigger on pageinit and close all the lines of sales order item sublist.
This code is written in Suitescript 2.1
/**
* @NApiVersion 2.1
* @NScriptType ClientScript
*/
define(['N/record'], (record)=>{
const pageInit = (context)=>{
const currRecord = context.currentRecord;
const lines = currRecord.getLineCount({
sublistId: 'item'
});
for(let i=0; i<lines; i++){
const lineNum = currRecord .selectLine({
sublistId: 'item',
line: i
});
currRecord.setCurrentSublistValue({
sublistId: 'item',
fieldId: 'isclosed',
value: true,
ignoreFieldChange: true
});
currRecord.commitLine({
sublistId: 'item'
});
}
}
return {
pageInit: pageInit
};
});
As you can see we are using selectline function to select the line first then using setCurrentSublistValue to finally set the field value and now we should not forget to commit the line
0
Subscribe to my newsletter
Read articles from Anurag Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Anurag Kumar
Anurag Kumar
I am a NetSuite Certified SuiteCloud Developer with over 8 years of work experience.