How to get and set a sublist in netsuite suitlet suitescript 2.0

Some Times we often need to create sublist to our suitelet here we are going to learn how create a sublist to suilet and then add data to the newly created sublist:

To create a new sublist use this:

var sublist = form.addSublist({
         id : ‘custpage_sublist’,
         type : ui.SublistType.LIST,
label : ‘people’

var name = sublist.addField({
id : ‘custpage_name’,
label : ‘Name’,
type : ui.FieldType.TEXT

To set data to newly created sublist use this:

         var sublist = form.getSublist({
id : ‘custpage_sublist’

id : ‘custpage_name’,
line : 0, // loop the line for all line number
value : ‘your name’