hi, how do we create a new pdf in new window in su...
# suitescript
r
hi, how do we create a new pdf in new window in suitelet in a loop? like if print is selected for 3 lines they would have their PDF's in new window i know how to create a pdf but it gets on the same page but idk about new window... window.open? i dont think so
t
Copy code
https.post.promise({
    url: onDemandPaymentSuitelet,
    body: onDemandReportCriteria
}).then( function (result){
    console.log('response:' + result);
    var anchorTag = document.createElement('a');
    anchorTag.href = dataEncoding + encodeURIComponent(result.body);
    anchorTag.download = reportFileName + fileDateTimstamp.getTime() + fileExt;
    document.body.appendChild(anchorTag);
    anchorTag.click();
    document.body.removeChild(anchorTag);
    console.log(result.toString());
}).catch(function (result){
    console.log(result.toString());
});
You can create a phantom A element and click it then remove it and it downloads it for the user
works in chrome but not sure on other browsers. It might complain about multiple downloads but you can allow it
r
it takes data from the suitelet and performs logic based on data in POST section and then generates a pdf.. i dont have a different suitelet for pdf, will work?
t
This is a different setup. I have a client script make a post to a suitelet on a button push. If you are just using a generic submit button I think you are limited to one pdf unless you combine them all using a pdfset in code and return it all as one