Hi all! Probably someone faced the problem like th...
# suitescript
d
Hi all! Probably someone faced the problem like this in the past. So I have a Suitelet that generates a big transaction report (the report MUST be one file, it's the main requirement). Sometimes the data is so large that context.response.writePage({ pageObject: renderer.renderAsPdf() }) gets timeout. It's not a problem for me to use the MapReduce in this case, but how to deliver the result PDF to the customer? I doubt it can go as email attachment due to its size.
b
you can try seeing if the more specialized ServerResponse.writeFile works better
otherwise i say generate a link to the file
d
Ok, thank you @battk. I also thought about the link, but where to store the PDF itself? I think that FileCabinet limit is 10MB and user don't want to store the file outside the NetSuite
b
you can generate larger pdfs as long as you dont read it
d
Oh, great. Didn't know that
a
You can also use promise and blob, no standard(API wise) but it should work.
Copy code
$ = window.jQuery;
var wurl = window.URL || window.webkitURL;

/* Adding an event listener to the Submit(Print) button */
$('input[type="submit"][value="Print"]').click( function(e) {

    e.preventDefault();
    var oSelectedOrders = getLinesData();
    if (oSelectedOrders.length) {

        var slURL = url.resolveScript(util.extend({}, oSLIDs));
        var xhr = new XMLHttpRequest();
        xhr.onreadystatechange = function() {

            if (this.readyState == 4 && this.status == 200){

                window.open(wurl.createObjectURL(this.response));
            }
        }

        xhr.open('POST', slURL);
        xhr.setRequestHeader("Content-Type", "application/json; charset=UTF-8");
        xhr.responseType = 'blob';
        xhr.send(JSON.stringify(oSelectedOrders));

    }
});
👀 1