Dashboard Customization

Scenario:

We need to create a html page and display it in the dashboard.

Solution:

  1. Create the html page.
  2. Upload the html page into the file cabinet.
  3. Create Portlet script.
  4. Include the html page url as iframe in the portlet.(script given below)
  5. Personalize dashboard->custom portlet->select the portlet script.

Portlet script:

/**
 * @NApiVersion 2.1
 * @NScriptType Portlet
 */
define(['N/ui/serverWidget'],
    /**
 * @param{render} render
 * @param{serverWidget} serverWidget
 */
    function (serverWidget) {
        /**
         * Defines the Portlet script trigger point.
         * @param {Object} params - The params parameter is a JavaScript object. It is automatically passed to the script entry
         *     point by NetSuite. The values for params are read-only.
         * @param {Portlet} params.portlet - The portlet object used for rendering
         * @param {string} params.column - Column index forthe portlet on the dashboard; left column (1), center column (2) or
         *     right column (3)
         * @param {string} params.entity - (For custom portlets only) references the customer ID for the selected customer
         * @since 2015.2
         */
        const render = (params) => {
            var portlet = params.portlet;
            portlet.title = 'CPE DASHBOARD';
    
            // URL of your external HTML page
            var htmlPageUrl = 'https://9267067.app.netsuite.com/core/media/media.nl?id=5319&c=9267067&h=rG4IsQcfZ3R0SohC85yhpPzDG_hNe679_oj2AOSYWyYtg3NP&_xt=.html';
    
            var iframeHtml = '<iframe src="' + htmlPageUrl + '" width="100%" height="1200px" style="border:none;"></iframe>';
            portlet.html = iframeHtml;


        }


        return {render}


    });


Leave a comment

Your email address will not be published. Required fields are marked *