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 Portlet Script Reference
Guidelines for Creating a Dashboard SuiteApp Icon
Portlet Script Samples

General Notices