0
votes

It seems that I am missing something when trying to add data to a form sublist I have created. The sublist is populated with the first row of data, but nothing else.
I've tried to use the list object for the ui, but it seems to be separate from the form. My goal here is to display a record, with several sublists (based on saved searches) that relate to that record.

Any help would be great.

Thank you

var mySearch = search1.load({
         id: 'customsearch511'
       });
var resultSet = mySearch.run();
var list = form.addSublist( {
          id: 'custpage_sublist',
          type : serverWidget.SublistType.LIST,
          label: 'Lines'
       });
resultSet.columns.forEach(function(col){// This adds columns to the sublist based on the search results
           list.addField({
                   id: col.name,
                   label: col.label,
                   type: serverWidget.FieldType.TEXT
                   });
           });
for(var i in results){
  var result = results[i];
  for(var k in result.columns){
    var test = result.columns[k];
    if(result.getText(result.columns[k])){ //This is to get the values of any select field in the search
        var fieldValue = result.getText(result.columns[k]
        )} 
    else{
        var fieldValue = result.getValue(result.columns[k]
        )};

    list.setSublistValue({
        id: result.columns[k].name,
        value: fieldValue,
        line: i                       
        });
    //Error out after the first row is entered.  When this loops back to the second line of the search results.          
    }
context.response.writePage(form);    
1

1 Answers

1
votes

You just need to do small correction in your code and it will be fine.

var a=Number(i);
sublist.setSublistValue({
id: result.columns[k].name,
value: fieldValue,
line: a
})

;

I have tested and it's working fine.

Good luck, Mayur