How email netsuite suitelet as pdf?

Hi,

I have developed suitelet script. I have to share it via email. But due to some reason, I can’t send external url. So, I want to store suitelet page in a pdf and share that pdf over email. How will it be possible. I will appreciate an advice,

 

I am attaching client script to Nestuite iframe suitelet to hide div element.

Here’s the strange part: 1.If I inspect the element in the browser’s developer tools and then execute document.getElementById('abc') in the console, it returns null. 2. But, if I copy the JSON path of the element in the developer tools and then execute document.getElementById('abc') in the console, it correctly returns the element.

Below in Netsuite client script:

//Client Script
function pageInit(scriptContext) {
    document.getElementById("uif37");
}

//i_frame suitelet
 if (context.request.method === 'GET') {

            var form = serverWidget.createForm({title: 'Monitoring System', hideNavBar: true});
           
            // Construct URLs for child Suitelets
            var fisrtiframeUrl = buildIframeUrl('scriptid', 'deployid');
            var secondiframeUrl = buildIframeUrl('scriptid', 'deployid);
          

            var fisrtiFrameHtml = "<iframe src='" + fisrtiframeUrl + "' id='view' width='50%' height='700px' scrolling='auto'  name='firstframeView' marginheight='0' marginwidth='0' frameborder='0'></iframe>";
            var secondiFrameHtml = "<iframe src='" + secondiframeUrl + "' id='view' width='50%' height='700px' scrolling='auto' name='secondframeView' marginheight='0' marginwidth='0' frameborder='0'></iframe>";
        

            var combinedHtml = fisrtiFrameHtml + secondiFrameHtml;

            var htmlField = form.addField({
                id: 'custpage_my_iframe',
                type: serverWidget.FieldType.INLINEHTML,
                label: 'Performance  iFrame'
            });
            htmlField.defaultValue = combinedHtml;
            form.clientScriptModulePath = 'SuiteScripts/cs_hide_div.js';


            form.addResetButton({label: 'Cancel'});

            context.response.writePage(form);
        }
    }

 

Beginner Asked on March 10, 2025 in SuiteScript.
Add Comment
3 Answer(s)

This seems quite complicated. Can I ask what that basic requirement / problem is here?

Advanced Answered on March 12, 2025.
Add Comment

Hi @chris Abbot,

Now my requirenment is,

I want to share suitelet page via email. I  cant check available without login checkbox due to some reason. Is there any way to share suitelet to email which should be accessible without Netsuite login.

I am thinking to show suitelet in a PDF,  But the problem is, I am getting suitelet response as HTML and I need to pass xml string to ,

let pdfFile = render.xmlToPdf({
                xmlString: xmlData,
            });

 

//Suitelet Script

function execute(context) {

        try {
            log.audit(‘Scheduled Script’, ‘Generating Dashboard PDF Snapshot’);
            var suiteletUrl = url.resolveScript({
                scriptId: ‘customscript_sut_daily_health_check’,
                deploymentId: ‘customdeploy_sut_daily_health_check’,
            });
            log.debug(“suiteletUrl”,suiteletUrl);
            var domain = url.resolveDomain({
                hostType: url.HostType.APPLICATION,
                accountId: 3389434
            });
            log.debug(“domain”,domain);
            let finalurl = ‘https://’+domain+suiteletUrl;
            log.debug(“finalurl”,finalurl);
            let suiteletResponse = https.requestSuitelet({
             scriptId: “customscript_sut_daily_health_check”,
                deploymentId: “customdeploy_sut_daily_health_check”,
            });
            log.debug(“suiteletResponse”, suiteletResponse);
            let xmlData = suiteletResponse.body;
            log.debug(“xmlData”,xmlData);
            // Render the PDF
            let pdfFile = render.xmlToPdf({
                xmlString: xmlData,
            });
            log.debug(“pdfFile”,pdfFile);
            var fileId = pdfFile.save();
            email.send({
                author: 115293,
                recipients: ‘monika.phalle@team.telstra.com’,
                subject: ‘Suitelet Snapshot’,
               body:pdfFile,
                attachments: [file.load({ id: fileId })]
            });
        } catch (error) {
            log.error(‘Error Generating PDF’, error);
        }
    }

 

Beginner Answered on March 13, 2025.
Add Comment

I’m not sure what you mean when you say “I want to share suitelet page via email”.

A Suitelet is a web page. Do you mean share the URL?

Advanced Answered on March 14, 2025.

If I share internal URL, user has no netsuite access. So I have to share suitelet UI design without login.

on March 15, 2025.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   SuiteMigration   Become a Sponsor