SuiteScript 2.x Portlet Script Type

Portlet scripts are run on the server and are rendered in the NetSuite dashboard.

The following portlet script types are supported:

The following image shows a form portlet and a links portlet displayed on the NetSuite dashboard.

SuiteScript 2.x Portlet Script Type page

You can designate that a portlet script should be used for a SuiteApp portlet. A SuiteApp portlet is a specialized type of custom portlet. It provides direct access from users’ dashboards to a SuiteApp installed in their account. This type of script is called a Dashboard SuiteApp portlet script. If a Dashboard SuiteApp portlet is included in a SuiteApp, a user can add a SuiteApp portlet to their dashboard from the Personalize Dashboard menu. For instructions, see SuiteApp Portlets. This type of portlet is supported for installed SuiteApps that include a dashboard component. A SuiteApp portlet script not only provides content for SuiteApp portlets. It also enables you to include your choice of graphics as branding for the icons that are shown for SuiteApp portlets in the Personalize Dashboard window.

To view content produced by a portlet script that is not intended for a SuiteApp portlet, a user must add a custom portlet to their dashboard and select the script in the portlet setup. For more information, see Custom Portlets and Adding a Portlet to a Dashboard.

For steps to create and deploy a portlet script, see Creating and Deploying a Portlet Script.

You can use SuiteCloud Development Framework (SDF) to manage portlet scripts as part of file-based customization projects. For information about SDF, see SuiteCloud Development Framework Overview. You can use the Copy to Account feature to copy an individual portlet script to another of your accounts. Each portlet script page has a clickable Copy to Account option in the upper right corner. For information about Copy to Account, see Copy to Account Overview.

You can use SuiteScript Analysis to learn about when the script was installed and how it performed in the past. For more information, see Analyzing Scripts.

See the following for more information about the Portlet Script type:

SuiteScript 2.x Portlet Script Samples

Simple Form Portlet Script Sample

For help with writing scripts in SuiteScript 2.x, see SuiteScript 2.x Hello World and SuiteScript 2.x Entry Point Script Creation and Deployment.

          /**
 *@NApiVersion 2.x
 *@NScriptType Portlet
 */

// This sample creates a portlet that includes a simple form with a text field and a submit button
define([], function() {
    function render(params) {
        var portlet = params.portlet;
        portlet.title = 'Simple Form Portlet';
        var fld = portlet.addField({
            id: 'text',
            type: 'text',
            label: 'Text'
        });
        fld.updateLayoutType({
            layoutType: 'normal'
        });
        fld.updateBreakType({
            breakType: 'startcol'
        });
        portlet.setSubmitButton({
            url: 'http://httpbin.org/post',
            label: 'Submit',
            target: '_top'
        });
    }

    return {
        render: render
    };
}); 

        

Inline HTML Portlet Script Sample

          /**
 *@NApiVersion 2.x
 *@NScriptType Portlet
 */

// This sample creates a portlet that displays simple HTML
define([], function() {
    function render(params) {
        params.portlet.title = 'My Portlet';
        var content = '<td><span><b>Hello!!!</b></span></td>';
        params.portlet.html = content;
    }

    return {
        render: render
    };
}); 

        

Links and Indents Portlet Script Sample

          /**
 *@NApiVersion 2.x
 *@NScriptType Portlet
 */

// This sample creates a portlet with two links
define([], function() {
    function render(params) {
        var portlet = params.portlet;
        portlet.title = 'Search Engines';
        portlet.addLine({
            text: 'NetSuite',
            url: 'http://www.netsuite.com/'
        });
        portlet.addLine({
            text: 'Oracle',
            url: 'http://www.oracle.com/'
        });
    }

    return {
        render: render
    };
}); 

        

Simple List Portlet Script Sample

Important:

This sample references a custom entity field with the ID custentity_multiselect. Before attempting to use this sample, you must either create a field with that ID or edit the sample so that it references an existing custom entity field in your account.

          /**
 *@NApiVersion 2.x
 *@NScriptType Portlet
 */

// This sample creates a portlet with a simple list
define(['N/search'], function(search) {
    function render(params) {
        var isDetail = (params.column === 2);
        var portlet = params.portlet;
        portlet.title = isDetail ? "My Detailed List" : "My List";
        portlet.addColumn({
            id: 'internalid',
            type: 'text',
            label: 'Number',
            align: 'LEFT'
        });
        portlet.addColumn({
            id: 'entity',
            type: 'text',
            label: 'ID',
            align: 'LEFT'
        });
        if (isDetail) {
            portlet.addColumn({
                id: 'email',
                type: 'text',
                label: 'E-mail',
                align: 'LEFT'
            });
            portlet.addColumn({
                id: 'custentity_multiselect',
                type: 'text',
                label: 'Multiselect',
                align: 'LEFT'
            });
        }
        var filter = search.createFilter({
            name: 'email',
            operator: search.Operator.ISNOTEMPTY
        });
        var customerSearch = search.create({
            type: 'customer',
            filters: filter,
            columns: ['internalid', 'entity', 'email', 'custentity_multiselect']
        });
        var count = isDetail ? 15 : 5;
        customerSearch.run().each(function(result) {
            portlet.addRow(result.getAllValues());
            return --count > 0;
        });
    }

    return {
        render: render
    };
}); 

        

Related Topics

SuiteScript 2.x Script Types
SuiteScript 2.x Bundle Installation Script Type
SuiteScript 2.x Client Script Type
SuiteScript 2.x Map/Reduce Script Type
SuiteScript 2.x Mass Update Script Type
SuiteScript 2.x RESTlet Script Type
SuiteScript 2.x Scheduled Script Type
SuiteScript 2.x Suitelet Script Type
SuiteScript 2.x User Event Script Type
SuiteScript 2.x Workflow Action Script Type

General Notices