分离 Suitelet 的 POST 请求
Separating the POST requests of a Suitelet
我的目标是将自定义提交按钮附加到向外部服务器发送 post 请求的 Suitelet。我遇到的问题是,在呈现页面时,form.addButton('submit','Submit', send(form));
中自定义按钮中的函数 send()
在加载页面时是 运行。因此,没有数据被发送到 send()
函数,因此没有得到正确处理。
据我了解,此问题与呈现 Suitelet 的原始 POST 请求有关,然后干扰了我要发送的 POST 请求。
我需要做的是将呈现表单的 POST 请求与发送表单的请求分开或区分。理想的做法是在用户事件脚本中完成此操作,但表单只能在 SS1.0 的 Suitelet 中使用...
有什么办法可以做到吗?我应该使用 SuiteScript 2.0 来实现吗?
下面是我的代码的样子:
function main(request, response){
var form = nlapiCreateForm('Submission Form');
form.addField('one', 'text', 'Field 1');
response.writePage(form);
form.addButton('submit','Submit', send(form));
}
function send(form){ process form data somewhere... }
当您在 Suitelet 上执行 send(form) 时,您实际上是 运行 函数。 form.addButton 方法的第三个参数接受一个字符串,所以你想做类似
的事情
form.addButton('submit','Submit', "alert('Sending form')")
如果你想构建自己的 POST,你可以添加一个完整的字符串化函数,尽管我认为只包含一个 form.addSubmitButton(label) 并发送表单数据会更容易到同一个 Suitelet,然后从那里您可以使用 nlapiRequestURL
通过 POST 发送该数据
我的目标是将自定义提交按钮附加到向外部服务器发送 post 请求的 Suitelet。我遇到的问题是,在呈现页面时,form.addButton('submit','Submit', send(form));
中自定义按钮中的函数 send()
在加载页面时是 运行。因此,没有数据被发送到 send()
函数,因此没有得到正确处理。
据我了解,此问题与呈现 Suitelet 的原始 POST 请求有关,然后干扰了我要发送的 POST 请求。 我需要做的是将呈现表单的 POST 请求与发送表单的请求分开或区分。理想的做法是在用户事件脚本中完成此操作,但表单只能在 SS1.0 的 Suitelet 中使用...
有什么办法可以做到吗?我应该使用 SuiteScript 2.0 来实现吗? 下面是我的代码的样子:
function main(request, response){
var form = nlapiCreateForm('Submission Form');
form.addField('one', 'text', 'Field 1');
response.writePage(form);
form.addButton('submit','Submit', send(form));
}
function send(form){ process form data somewhere... }
当您在 Suitelet 上执行 send(form) 时,您实际上是 运行 函数。 form.addButton 方法的第三个参数接受一个字符串,所以你想做类似
的事情form.addButton('submit','Submit', "alert('Sending form')")
如果你想构建自己的 POST,你可以添加一个完整的字符串化函数,尽管我认为只包含一个 form.addSubmitButton(label) 并发送表单数据会更容易到同一个 Suitelet,然后从那里您可以使用 nlapiRequestURL
通过 POST 发送该数据