NetSuite Client-Side Script to Hide Buttons using jQuery

Below is a NetSuite beforeLoad server-side 2.0 SuiteScript to create a hidden HTML field that allows you to inject browser-based client-side JavaScript (not a NetSuite conventional client script)  that will then find the buttons and use CSS to change the visibility to hidden via JQuery.

//create an inline html field
var hideFld = context.form.addField({
	id:'custpage_hide_buttons',
	label:'not shown - hidden',
	type: serverWidget.FieldType.INLINEHTML
});

 
//for every button you want to hide, modify the scr += line
var scr = "";
scr += 'jQuery("#print").hide();';
scr += 'jQuery("#addmessage").hide();';
scr += 'jQuery("#addcontact").hide();';

//push the script into the field so that it fires and does its handy work
hideFld.defaultValue = "<script>jQuery(function($){require([], function(){" + scr + ";})})</script>"

Leave a comment

Your email address will not be published. Required fields are marked *