Anurag Kumar
Anurag Kumar

Reputation: 195

Create sublist and add data in suitescript 2.0

How Can i create and add data to sublist in Suitlet. My problem is I want first field as checkbox and in rest of the fields i wanto put item list from sales order.. But it's not working.. Even checkbox is not appearing . Can you please let me know how to proceed.

/**
* @NApiVersion 2.0
* @NScriptType suitelet
*/

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


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

var form = serverWidget.createForm({
 title : 'Simple Form with List type Sublist'
});
var sublist = form.addSublist({
 id : 'sublist',
 type : serverWidget.SublistType.LIST,
 label : 'List Type Sublist'
});
var checkbox = sublist.addField({
 id : 'id',
 label : 'Internal ID',
 type : serverWidget.FieldType.CHECKBOX
});
checkbox.updateDisplayType({displayType: serverWidget.FieldDisplayType.ENTRY});

var itm_id = sublist.addField({
 id : 'item_id',
 label : 'Internal ID',
 type : serverWidget.FieldType.TEXT
});


//sublist.setSublistValue({
// id : 'id',
// line : 1,
// value : "Text"
//});

//sublist.setSublistValue({
// id : 'item_id',
//line : 1,
// value : "Text"
//});


context.response.writePage(form);

 }

}

return {
 onRequest: onRequest
 };

 });

Upvotes: 1

Views: 4865

Answers (1)

Anurag Kumar
Anurag Kumar

Reputation: 195

I was able to create. Please check below

/**
* @NApiVersion 2.0
* @NScriptType suitelet
*/

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


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


var form = serverWidget.createForm({
 title : 'Simple Form with List type Sublist'
});
var sublist = form.addSublist({
 id : 'sublist',
 type : serverWidget.SublistType.LIST,
 label : 'List Type Sublist'
});

var check = sublist.addField({
 id : 'custpage_id',
 label : 'Check',
 type : serverWidget.FieldType.CHECKBOX
});
check.updateDisplayType({displayType: serverWidget.FieldDisplayType.ENTRY});

var itm_id = sublist.addField({
 id : 'custpage_item',
 label : 'Item Id',
 type : serverWidget.FieldType.TEXT
});


// Set Sublist data

var sublist = form.getSublist({
 id : 'sublist'
});



sublist.setSublistValue({
id : 'custpage_item',
line : 0,
value : "Text"
});

sublist.setSublistValue({
id : 'custpage_item',
line : 1,
value : "Text"
});


sublist.setSublistValue({
id : 'custpage_item',
line : 2,
value : "Text"
});






context.response.writePage(form);

 }else{

 }

}

return {
 onRequest: onRequest
 };

 });

Upvotes: 3

Related Questions