This article explains how to use a Client Script in NetSuite to hide a specific custom tab on record forms and automatically switch to the standard “Items” tab when the record is loaded.
Objective:
To improve user experience or enforce business process rules by:
- Hiding a custom tab with internal ID
custom1437. - Automatically navigating the user to the “Items” tab on page load.
Sample code:
function pageInit(scriptContext) {
try {
let currentRecordObj = scriptContext.currentRecord; // Access the current record
// Fetch DOM elements by their rendered NetSuite IDs
let tab = document.getElementById('custom1437txt'); // ID of the custom tab
let itemsTab = document.getElementById('itemstxt'); // ID of the standard Items tab
// Hide the custom tab if it exists
if (tab) {
tab.style.display = 'none';
}
// Automatically switch to the Items tab
if (itemsTab) {
itemsTab.click();
}
} catch (e) {
log.error("Error in pageInit", e);
}
}