我最近开始了 SuiteScript 2.0 的开发,并坚持以下几点:
客户需要自定义表单。该表单有 3 个标题字段:
地点、周数和子公司。根据他在这三个字段中输入的值,需要返回自定义记录的值。
所以我已经构建了自定义表单,但被困在正确的功能上。我想我可以通过在填写三个标题记录中的值后从自定义按钮调用客户端脚本来做到这一点。所以我的代码是:
/**
* @NApiVersion 2.x
* @NScriptType Suitelet
* @NModuleScope SameAccount
*/
define(['N/record', 'N/redirect', 'N/ui/serverWidget'],
/**
* @param {record} record
* @param {redirect} redirect
* @param {serverWidget} serverWidget
*/
function(record, redirect, serverWidget) {
/**
* Definition of the Suitelet script trigger point.
*
* @param {Object} context
* @param {ServerRequest} context.request - Encapsulation of the incoming request
* @param {ServerResponse} context.response - Encapsulation of the Suitelet response
* @Since 2015.2
*/
function onRequest(context) {
var request = context.request;
var response = context.response;
var form = serverWidget.createForm({
title : 'Planning',
hideNevBar : false
});
var LocationGrp = form.addFieldGroup({
id : 'custpage_grp_main',
label : 'Location'
});
var PlanningGrp = form.addFieldGroup({
id : 'custpage_grp_sub',
label : 'Planning'
});
var locatieFld = form.addField({
id : 'custpage_location',
type: serverWidget.FieldType.SELECT,
label : 'Location',
source : 'location',
container : 'custpage_grp_main'
});
var subsidiaryFld = form.addField({
id : 'custpage_subsidiary',
type: serverWidget.FieldType.SELECT,
label : 'Subsidiary',
source : 'subsidiary',
container : 'custpage_grp_main'
});
var weekFld = form.addField({
id : 'custpage_weeknr',
type: serverWidget.FieldType.SELECT,
label : 'Weeknumber',
source : '500',
container : 'custpage_grp_main'
});
var sublijst = form.addSublist({
id : 'custpage_lines',
type: serverWidget.SublistType.INLINEEDITOR,
label : 'LINES'
});
var itemFld = sublijst.addField({
id : 'custpage_item',
type : serverWidget.FieldType.SELECT,
source : 'item',
label : 'Item'
});
// Buttons
form.addButton({
id: 'getval',
label: 'Get lines',
functionName: 'setButton'
});
form.clientScriptModulePath = './script.js';
response.writePage(form);
}
return {
onRequest: onRequest
};
});
但是,我不确定在客户端脚本中使用什么代码来检索在线上的“项目”。
包含所有项目行的自定义记录有四列:
地点、周数、子公司和项目。
谁能提供帮助(我的问题有点连贯)?