Hello all,
I wonder if anybody out there has successfully embedded an NSAW/OAC visualization into an iframe on a custom portlet in NetSuite. I have been trying to do this, but the portlet always displays an error that the site refuses to connect. I have followed the OAC instructions for setting a safe domain to allow embedding, but nothing works. Below is my portlet script, which works fine with other web pages.
/**
- @NApiVersion 2.x
- @NScriptType Portlet
- @NModuleScope SameAccount
*/
define(['N/runtime', 'N/log'], function(runtime, log) {/**- Main entry point for the portlet.
- @param {Object} params - Object containing the portlet and column info.
- @param {Object} params.portlet - The portlet object.
- @param {number} params.column - Column position index: 1 = left, 2 = middle, 3 = right.
*/
function render(params) {
var portlet = params.portlet;// Retrieve the script parameters.
var sEmbeddedURL = runtime.getCurrentScript().getParameter({
name: 'custscript_st_customportletiframeurl'
});
var sEmbeddedUser = runtime.getCurrentScript().getParameter({
name: 'custscript_st_customportletiframeuser'
});
var sEmbeddedPass = runtime.getCurrentScript().getParameter({
name: 'custscript_st_customportletiframepass'
});// Set the portlet title.
portlet.title = 'NetSuite Analytics Warehouse';// Construct the HTML for the portlet.
var html = [
'<html>',
'<head></head>',
'<body>',
'<p>User: ' + sEmbeddedUser + '</p>',
'<p>Password: ' + sEmbeddedPass + '</p>',
'<iframe src="' + sEmbeddedURL + '" height="1200" style="width: 100%; overflow: hidden; margin-top: -80px;" scrolling="no" title="Dashboard UI #1 : Project management with Charts" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true"></iframe>',
'</body>',
'</html>'
];// Log the HTML for debugging.
log.debug({
title: 'inline html',
details: html.join('')
});// Set the portlet content.
portlet.html = html.join('');
}
/**- Utility function to sanitize HTML.
- @param {string} str - The string to sanitize.
- @return {string} - The sanitized string.
*/
function convert(str) {
str = str.replace(/&/g, "&");
str = str.replace(/>/g, ">");
str = str.replace(/</g, "<");
str = str.replace(/"/g, """);
str = str.replace(/'/g, "'");
return str;
}
return {
render: render
};
});