ANS-0690 · SUITESCRIPT DEVELOPMENT
How to Add Custom Buttons to Subtabs or Sublists in NetSuite
Understand the standard NetSuite approach for integrating custom buttons, primarily on sublists, and modern SuiteScript methods.
Short answer
In NetSuite, buttons are typically added to sublists rather than directly to subtabs. While older methods might have involved INLINEHTML fields for custom links, the recommended and supported approach for adding buttons to sublists in modern NetSuite SuiteScript 2.x is to use the sublist.addButton() method, ensuring better compatibility and maintainability.
Scenario
Users often seek to enhance NetSuite forms by adding custom buttons to specific sections. A common requirement is to place a button on a subtab to trigger a custom action, such as opening a new window or executing a script. The challenge lies in identifying the correct and supported method for button placement within the NetSuite UI structure.
Solution
Buttons in NetSuite are primarily designed to be added to sublists rather than directly to subtabs. While it was historically possible to use an INLINEHTML field to embed a simple link that functions as a button, this method is now marked for deprecation on most form pages (excluding Suitelet Forms) and is generally not the recommended approach for adding interactive elements.For modern NetSuite development using SuiteScript 2.x, the standard and supported method for adding buttons to sublists is to utilize the sublist.addButton() function. This provides a robust and maintainable way to integrate custom actions directly into sublist interfaces.An example of adding a button to a sublist using SuiteScript 2.x:
javascript/** * @NApiVersion 2.x * @NScriptType UserEventScript */define(['N/ui/serverWidget'], function(serverWidget) { function beforeLoad(context) { if (context.type === context.UserEventType.VIEW || context.type === context.UserEventType.EDIT) { var form = context.form; var sublist = form.getSublist({ id: 'recmachcustrecord_your_sublist_id' }); // Replace with your sublist ID if (sublist) { sublist.addButton({ id: 'custpage_mycustombutton', label: 'My Custom Action', functionName: 'myClientScriptFunction' }); } } } return { beforeLoad: beforeLoad };});This script snippet demonstrates how to add a button to a sublist. The functionName parameter would refer to a client-side script function that defines the button's action.
Expert NetSuite Support
Need help with this NetSuite issue?
SuiteScript Development consulting and configuration support
