如何从SuiteScript 2.0 Suitelet for POST检索值?

时间:2018-10-29 13:25:24

标签: netsuite suitescript2.0

我在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
}

1 个答案:

答案 0 :(得分:1)

对于SS1.0,您可以从请求中获取值

request.getParameter('custpage_sdr_financing_price');