How to remove standard and custom buttons using user event.

By using the Inline HTML field we can remove any buttons from the NetSuite records.

define(['N/ui/serverWidget'],
    function (serverWidget) {
        function beforeLoad(scriptContext) {
            try {
                if (scriptContext.type == 'edit') {//work in edit mode
                    //create an inline html field
                    var hideFld = scriptContext.form.addField({
                        id: 'custpage_hide_buttons',
                        label: 'hideButton',
                        type: serverWidget.FieldType.INLINEHTML
                    });


                    //JQuery script for hiding button
                    var scr = "";
                    scr += 'jQuery("#tdbody_newmessage").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>"
                }
            } catch (e) {
                log.error("error@beforeLoad", e)
            }
        }
        return {
            beforeLoad: beforeLoad
        }
    });

Leave a comment

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