如何从 POST 的 SuiteScript 2.0 Suitelet 检索值?
How to retrieve values off of SuiteScript 2.0 Suitelet for POST?
我在 GET 方法下为我创建的 Suitelet 创建了一个表单。然后,在代码的 POST 部分,我试图从相关表单中检索自由格式的文本字段值。如何才能做到这一点?我试图以这种方式获取值,但显然它不能从表单对象中获取,但是,我不确定这是如何在 SuiteScript 中完成的,因为我在 SuiteScripts 上完成的教程没有涵盖如何检索SuiteScript 2.0 中的 Suitelet 值。
if (request.method == 'GET'){
var form = serverWidget.createForm({
title: 'Sales Order Update'
});
var financingPriceField = form.addField({
id: 'custpage_sdr_financing_price',
type: serverWidget.FieldType.TEXT,
label: 'Financing Price'
});
var submitButton = form.addSubmitButton({
label: 'Save SO Data'
});
response.writePage(form);
}
else // If POSTing
{
var salesOrder = record.load({
type: record.Type.SALES_ORDER,
id: 9976 // Using hard-coded id for testing only
isDynamic: true
});
// This portion of the code is failing to get any value
// When attempting to do so will result in a TypeError
// 'Cannot call method 'getValue' of undefined
var financingPrice = form.getValue('custpage_sdr_financing_price');
// Will save sales order and copy value to SO in code below, not shown in example
}
对于 SS1.0,您从请求中获取值
request.getParameter('custpage_sdr_financing_price');
我在 GET 方法下为我创建的 Suitelet 创建了一个表单。然后,在代码的 POST 部分,我试图从相关表单中检索自由格式的文本字段值。如何才能做到这一点?我试图以这种方式获取值,但显然它不能从表单对象中获取,但是,我不确定这是如何在 SuiteScript 中完成的,因为我在 SuiteScripts 上完成的教程没有涵盖如何检索SuiteScript 2.0 中的 Suitelet 值。
if (request.method == 'GET'){
var form = serverWidget.createForm({
title: 'Sales Order Update'
});
var financingPriceField = form.addField({
id: 'custpage_sdr_financing_price',
type: serverWidget.FieldType.TEXT,
label: 'Financing Price'
});
var submitButton = form.addSubmitButton({
label: 'Save SO Data'
});
response.writePage(form);
}
else // If POSTing
{
var salesOrder = record.load({
type: record.Type.SALES_ORDER,
id: 9976 // Using hard-coded id for testing only
isDynamic: true
});
// This portion of the code is failing to get any value
// When attempting to do so will result in a TypeError
// 'Cannot call method 'getValue' of undefined
var financingPrice = form.getValue('custpage_sdr_financing_price');
// Will save sales order and copy value to SO in code below, not shown in example
}
对于 SS1.0,您从请求中获取值
request.getParameter('custpage_sdr_financing_price');