Hello guys, I'm trying to create a PDF thru Suitel...
# suitescript
g
Hello guys, I'm trying to create a PDF thru Suitelet Script 2.0, but I can't see anything on the response; the generatePDF function returns a renderer.renderAsString() object.
Copy code
define(['N/record', 'N/log',  'N/runtime','N/file', 'N/render'],
 function(record, log, runtime, file, render) {
     function onRequest(context) {
         log.debug('onRequest', '***START***');
         log.debug('onRequest', 'context= ' + context);
         var xml='';

         try {
            log.debug('try', '*** ENTER ***');
            log.debug('Request Method', 'context.request.method= ' + context.request.method);
            if (context.request.method === 'POST') {
                log.debug('POST',JSON.stringify(context));
                var getReqBody = JSON.parse(context.request.body);
                log.debug('getReqBody', getReqBody);
                
                xml=generatePDF(getReqBody);

                log.debug('POST', 'xml= ' + xml);

                if(xml){
                    context.response.renderPdf(xml);
                }
            } 
                
         }
         catch (e) {
             log.error('Error:', e);
         }
     }