Jira Code : BLL-228
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.
/**
* @NApiVersion 2.1
* @NScriptType UserEventScript
*/
define(['N/record', 'N/ui/serverWidget'],
/**
* @param{record} record
* @param{serverWidget} serverWidget
*/
(record, serverWidget) => {
/**
* Defines the function definition that is executed before record is loaded.
* @param {Object} scriptContext
* @param {Record} scriptContext.newRecord - New record
* @param {string} scriptContext.type - Trigger type; use values from the context.UserEventType enum
* @param {Form} scriptContext.form - Current form
* @param {ServletRequest} scriptContext.request - HTTP request information sent from the browser for a client action only.
* @since 2015.2
*/
const beforeLoad = (scriptContext) => {
let hideFld = scriptContext.form.addField({
id: 'custpage_hide_buttons',
label: 'not shown - hidden',
type: serverWidget.FieldType.INLINEHTML
});
let scr = "";
scr += 'jQuery("#attach").hide();';
scr += 'jQuery("#newrecrecmachcustrecord_jj_parent_link").hide();';
scr += 'jQuery("#newrec783").hide();';
hideFld.defaultValue = "<script>jQuery(function($){require([], function(){" + scr + ";})})</script>"
}
return {beforeLoad}
});