0

Basically I have a Suitelet that 2 buttons:

1 addSubmitButton 1 addButton

I would like the add button to redirect to a POST context along with its data.

So far i've used resolveURL and https.post.promise on a Client Script. I can redirect to the URL using window.open, but I can't seem to pass the data as well from the post method.

Here's my current script:

SUITELET:

var btnPrint = formGet.addButton({
    id:'custpage_print_button',
    label: 'Email To Customers',
    functionName:'emailButton('+scriptId +','+deploymentId+')'
});

CLIENT:

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');
}
chris
  • 789
  • 4
  • 16

1 Answers1

0

The https.post.promise is a Promise. You'll need to do something with that as it's not a 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){
    });;
ehcanadian
  • 1,738
  • 1
  • 15
  • 23