Wednesday, October 24, 2018

Make certain column fields in a 'list' type sublist editable

To make column fields editable in a 'list' type sublist on a Suitelet form, set the setDisplayType to type 'entry'. Use the following code as guide:

function createForm(request,response){
    //create form
    var form = nlapiCreateForm('My Form');
    form.addSubmitButton('Submit');
    //create sublist
    var sublist = form.addSubList('custpage_mysublist','list','Sublist');
    //add editable field
    sublist.addField('custpage_mysublistfield','text','test sublist field').setDisplayType('entry');
    sublist.addField('custpage_mysublistcb','checkbox','checkbox');
    //add un-editable field
    sublist.addField('custpage_mysublistfield2','text','test sublist field 2');
   
    //set values to fields
    sublist.setLineItemValue('custpage_mysublistfield','1','sublist field 1');
    sublist.setLineItemValue('custpage_mysublistfield2','1','sublist field 2');
   
    //send response
    response.writePage(form);
}
 
Note:
The record where the column field is sourced from should be saved to commit the changes made to the editable field.

No comments:

Post a Comment