Netsuite 如何在Suitelet的列表(serverWidget.list)中添加复选框
我刚开始使用NetSuite和SuiteScript2.0。这是我的需要: 我需要根据记录创建一个列表,然后我需要在列表中选择所需的行,以便仅为所选行调用函数 目前,我创建了一个列表(使用N/ui/serverWidget.list对象),并且我能够使用N/search模块显示记录中的行以提供列表,我还在列表上创建了一个按钮,以便调用函数 我被卡住的地方是,选择列表中出现的行,以便仅为所选行触发函数 使用API,我尝试为列表添加一列类型为CHECKBOX的列,但它不起作用 你知道实现这一目标的最佳方法吗Netsuite 如何在Suitelet的列表(serverWidget.list)中添加复选框,netsuite,suitescript2.0,Netsuite,Suitescript2.0,我刚开始使用NetSuite和SuiteScript2.0。这是我的需要: 我需要根据记录创建一个列表,然后我需要在列表中选择所需的行,以便仅为所选行调用函数 目前,我创建了一个列表(使用N/ui/serverWidget.list对象),并且我能够使用N/search模块显示记录中的行以提供列表,我还在列表上创建了一个按钮,以便调用函数 我被卡住的地方是,选择列表中出现的行,以便仅为所选行触发函数 使用API,我尝试为列表添加一列类型为CHECKBOX的列,但它不起作用 你知道实现这一目标的最
谢谢。下面是一个使用Suitelet将复选框添加到子列表的示例。您可以在客户端脚本中通过在行上循环并检查字段是否为true来处理它们
function onRequest(context) {
// Create the form
function createForm() {
try {
var form = serverWidget.createForm({
title: 'My Form',
hideNavBar: false
});
// In the client script, handle the checked lines by looping over the
// custpage_table sublist and looking to see if custpage_wo_process is true
form.clientScriptModulePath = 'SomeScript.js';
form.addButton({
id: 'custpage_myaction',
label: 'Process',
functionName: 'printRecords'
});
// Add a sublist to the form
var sublist = form.addSublist({
id: 'custpage_table',
type: serverWidget.SublistType.LIST,
label: 'Records to Process'
});
// Show a 'Mark All' button
sublist.addMarkAllButtons();
// Add an internalid to track the line item
var idField = sublist.addField({
id: 'custpage_rec_id',
label: 'Internal ID',
type: serverWidget.FieldType.TEXT
});
idField.updateDisplayType({
displayType: serverWidget.FieldDisplayType.HIDDEN
});
// Add a checkbox to mark which records should be processed
var printField = sublist.addField({
id: 'custpage_rec_process',
label: 'Process',
type: serverWidget.FieldType.CHECKBOX
});
// return the form and sublist
return {form: form, sublist: sublist};
} catch (e) {
log.error('Error creating form.', e);
}
}
function handleGet() {
var myForm = createForm();
if (myForm) {
// Get the form
var form = myForm.form;
// Get the sublist
var sublist = myForm.sublist;
// Do a search, etc to get the records to add to the sublist
var addResults = fetchSearchResult();
// Add the values to the sublist
for (var i = 0; i < addResults.length; i++) {
sublist.setSublistValue({
id: 'custpage_rec_id',
line: i,
value: addResults[i].id
});
}
context.response.writePage(form);
}
}
if (context.request.method === 'GET') {
handleGet();
}
}
函数onRequest(上下文){
//创建表单
函数createForm(){
试一试{
var form=serverWidget.createForm({
标题:“我的表格”,
hideNavBar:错误
});
//在客户端脚本中,通过在
//custpage\u table子列表,查看custpage\u wo\u流程是否正确
form.clientScriptModulePath='SomeScript.js';
form.addButton({
id:“custpage_myaction”,
标签:“进程”,
functionName:'printRecords'
});
//将子列表添加到表单中
var sublist=form.addSublist({
id:“custpage_表”,
类型:serverWidget.SublistType.LIST,
标签:“要处理的记录”
});
//显示“全部标记”按钮
sublist.addMarkAllButtons();
//添加内部ID以跟踪行项目
var idField=sublist.addField({
id:'custpage\u rec\u id',
标签:“内部ID”,
类型:serverWidget.FieldType.TEXT
});
idField.updateDisplayType({
displayType:serverWidget.FieldDisplayType.HIDDEN
});
//添加复选框以标记应处理哪些记录
var printField=sublist.addField({
id:'custpage\u rec\u process',
标签:“进程”,
类型:serverWidget.FieldType.CHECKBOX
});
//返回表单和子列表
返回{form:form,sublist:sublist};
}捕获(e){
log.error('创建表单时出错',e);
}
}
函数handleGet(){
var myForm=createForm();
如果(我的表格){
//拿到表格
var form=myForm.form;
//获取子列表
var sublist=myForm.sublist;
//执行搜索等操作,以获取要添加到子列表的记录
var addResults=fetchSearchResult();
//将值添加到子列表中
对于(var i=0;i
谢谢!那正是我的需要。serverWidget.List对象提供的可能性不多,serverWidget.Sublist对象提供的可能性更多。它们是命名列表和子列表这一事实非常令人困惑,因为您可以将子列表对象用作顶级列表。