如何将数据行添加到 Suitelet 子列表 (serverWidget.createform.addSublist)
How do I add lines of data to a Suitelet Sublist (serverWidget.createform.addSublist)
我在尝试将数据添加到我创建的表单子列表时似乎遗漏了一些东西。
子列表填充了第一行数据,但没有其他数据。
我已经尝试使用 ui 的列表对象,但它似乎与表单分开。我的目标是显示一条记录,其中包含与该记录相关的多个子列表(基于保存的搜索)。
任何帮助都会很棒。
谢谢
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);
你只需要在你的代码中做一些小的修正就可以了。
var a=Number(i);
sublist.setSublistValue({
id: result.columns[k].name,
value: fieldValue,
line: a
})
;
我已经测试过,它工作正常。
祝你好运,
马约尔
我在尝试将数据添加到我创建的表单子列表时似乎遗漏了一些东西。
子列表填充了第一行数据,但没有其他数据。
我已经尝试使用 ui 的列表对象,但它似乎与表单分开。我的目标是显示一条记录,其中包含与该记录相关的多个子列表(基于保存的搜索)。
任何帮助都会很棒。
谢谢
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);
你只需要在你的代码中做一些小的修正就可以了。
var a=Number(i);
sublist.setSublistValue({
id: result.columns[k].name,
value: fieldValue,
line: a
})
;
我已经测试过,它工作正常。
祝你好运, 马约尔