N/portlet Module Features for SuiteScript Customization
The N/portlet module allows developers to resize and refresh form portlets in SuiteScript, enhancing dashboard usability and functionality.
TL;DR Opening
The N/portlet module in SuiteScript enables developers to resize and refresh form portlets on the NetSuite dashboard. This capability is crucial for optimizing user interaction and enhancing functionality within custom applications.
What is the N/portlet Module?
The N/portlet module is designed for managing portlet functionalities within the NetSuite environment. By using this module, developers can improve the usability of form portlets by allowing immediate adjustments in size and content refreshing directly from client scripts.
Key Members of the N/portlet Module
The following methods are available to manipulate portlet size and content:
| Member | Type | Return Type | Supported Script Types | Description |
|---|---|---|---|---|
portlet.resize() | Method | void | Client scripts | Resizes a form portlet immediately. |
portlet.refresh() | Method | void | Client scripts | Refreshes a form portlet immediately. |
Using N/portlet Methods
Both methods can be invoked in client scripts to enhance the user interface. For example, you might use portlet.resize() to allow users to adjust the portlet dimensions based on their preferences or display current information dynamically using portlet.refresh(). Consider incorporating these methods strategically to improve the overall responsiveness of your dashboard.
Sample Code for Portlet Creation
The following script demonstrates how to implement the N/portlet module to create a form portlet that users can interact with:
1/**2 * @NApiVersion 2.x3 * @NScriptType Portlet4 * @NScriptPortletType form5 */6 7define([], function() {8 function render(context) {9 var portletObj = context.portlet;10 portletObj.title = 'Test Form Portlet';11 setComponentsForResize();12 setComponentsForRefresh();13 14 function setComponentsForResize() {15 var DEFAULT_HEIGHT = '50';16 var DEFAULT_WIDTH = '50';17 var inlineHTMLField = portletObj.addField({18 id: 'divfield',19 type: 'inlinehtml',20 label: 'Test inline HTML'21 });22 inlineHTMLField.defaultValue = '<div id=\'divfield_elem\' style=\'border: 1px dotted red; height: ' + DEFAULT_HEIGHT + 'px; width: ' + DEFAULT_WIDTH + 'px;\'></div>';23 }24 }25 return {26 render: render27 };28});Who This Affects
This functionality primarily affects:
- Developers: They can create adaptive dashboards based on user needs.
- Administrators: Enhanced dashboard functionality can lead to better user engagement and data visualization.
Key Takeaways
- The N/portlet module enhances dashboard usability through resizable and refreshable form portlets.
- It includes two main methods:
portlet.resize()andportlet.refresh(), supporting dynamic user interfaces. - Developers can create customized forms using the provided sample code to implement portlet features effectively.
Frequently Asked Questions (4)
Do I need to enable a feature flag for the N/portlet module to work?
What script types support the N/portlet resize and refresh methods?
How can I use the N/portlet module to enhance user interaction on my dashboard?
What should developers consider when incorporating N/portlet methods into their dashboards?
Was this article helpful?
Advertising
Reach Portlets Professionals
Put your product in front of NetSuite experts who work with Portlets every day.
Sponsor This Category