基本上我有一个2个按钮的套件:
1 添加提交按钮 1 个添加按钮
我希望添加按钮与其数据一起重定向到 POST 上下文。
到目前为止,我已经在客户端脚本中使用了 resolveURL 和 https.post.promise。我可以使用 window.open 重定向到 URL,但我似乎也无法从 post 方法传递数据。
这是我目前的脚本:
套房:
var btnPrint = formGet.addButton({
id:'custpage_print_button',
label: 'Email To Customers',
functionName:'emailButton('+scriptId +','+deploymentId+')'
});
客户:
function emailButton(suiteletScriptId,suiteletDeploymentId){
var suiteletURL = url.resolveScript({
scriptId : suiteletScriptId,
deploymentId : suiteletDeploymentId,
});
var header=[];
header['Content-Type']='application/json';
var postData={'hello':'hi'};
var response=https.post.promise({
url: suiteletURL,
headers:header,
body:postData
});
alert('response: ' + response.body.toString());
window.open('"+suiteletURL+"','_blank');
}
https.post.promise
是一个承诺。你需要做点什么,因为它不是ServerResponse
。
https.post.promise({
url: suiteletURL,
headers:header,
body:postData
}).then(function(response){
if(response && response.body){
alert('response: ' + response.body.toString());
}
}).catch(function(reason){
});;