/**
* @NApiVersion 2.1
* @NScriptType Portlet
*/
define([‘N/ui/serverWidget’, ‘N/log’, ‘N/url’, ‘N/https’,‘N/runtime’], (serverWidget, log, url, https,runtime) => {
function render(params) {
try {
let portlet = params.portlet;
portlet.title = ‘Report’;
// Get current user
let currentUser = runtime.getCurrentUser();
log.debug(‘Current User’, currentUser);
let currentUserId = currentUser.id;
log.debug(“currentUserId”,currentUserId);
// Build the URL to the Suitelet
let suiteletUrl = url.resolveScript({
scriptId: ‘customscript_jj_sl_sales_quota_eqcus_497’,
deploymentId: ‘customdeploy_jj_sl_sales_quote_rpt_eocus’,
returnExternalUrl: true
});
// Append currentUserId as a query parameter
suiteletUrl += `&userId=${currentUserId}`;
// Create the HTML for the iframe
let iframeHtml = `
<iframe src=”${suiteletUrl}” width=”100%” height=”200″ style=”border:none;”>
</iframe>
`;
// Add inline HTML to portlet
portlet.addField({
id: ‘custpage_iframe_content’,
type: serverWidget.FieldType.INLINEHTML,
label: ‘Iframe Content’
}).defaultValue = iframeHtml;
} catch (e) {
log.debug(“Error embedding Suitelet”, e);
}
}
return {
render: render
};
});