Marty Zigman

Conversations with Marty Zigman

Certified Administrator • ERP • SuiteCloud

Marty Zigman LinkedIn

Marty Zigman

Holding all three official certifications, Marty is regarded as the top NetSuite expert and leads a team of senior professionals at Prolecto Resources, Inc.. He is a former Deloitte & Touche CPA and has held CTO roles. For over 30 years, Marty has produced leadership in ERP, CRM, and eCommerce business systems. Contact Marty to set up a conversation.

BiographyYouTubeLinkedInX (Twitter)

29 thoughts on “Learn how to Hide NetSuite Sublist Buttons and Other HTML Elements

  1. Hey Marty,

    I tried this out, but I’m getting the following error:

    TypeError: Cannot read property “FieldType” from undefined (/SuiteScripts/hide_buttons.js#13)

    Line 13 is the var hideFld section. Thoughts?

  2. Hi Marty,

    Great thanks for you blog, it is very useful.
    We have a similar issue in our company. We need to hide the component sublist from the item forms and any transaction forms where this is shown as it contains very sensitive information and only a really small number of person can have access to this (read and/or write).
    Can we consider this in the same way?

    Thanks
    David

  3. Hi Marty,

    This does not seem to work on the LineInit function.

    Do you have an alternative for this? My goal is to hide the ‘add,remove, etc’ buttons from a sublist.

    Regards,

  4. Hi Marty

    Great tip! Very useful.

    In a similar vein, are you aware if there is a way to change the colour of the native buttons on forms?

    I have tried:

    var scr = ‘jQuery(“#tdbody_custpage_printdocumentsv2”).css(“backgroundColor”, “#blue”);’;

    But no result.

    custpage_printdocumentsv2 is the internal ID of the button created with UES.

    Cheers

    Steve

  5. Marty,

    You mentioned Client Script 2.0 which I think is misleading since you should be putting this code as a UserEvent Script which triggers a script on the client side. Client Scripts don’t have a beforeLoad trigger and they don’t have context.form and you must use a UserEvent script for contexts such as ‘view’ as client scripts don’t trigger on those contexts.

    I just want to help those folks out here who are confused such as Steven above.

    I’ve done similiar work here mimicking the message 2.0 api’s using userEvent scripts to create a automated alerts for transactions within configurable saved searches.

    Thanks – Brian

  6. Hi Marty,

    Great Article, I am new to scripting in netsuite, how to do get this script to trigger before the record is loaded?

    Thanks

    Mat

  7. Is there any way to apply this type of script to a Dashboard Tile portlet – I am trying to hide some text on the Tile using jQuery but it seems the Tiles are encased with iFrames, so I am struggling to get any jQuery placed elsewhere on the page (i.e. in a custom HTML Portlet) to impact the Tiles

  8. I noticed recent activity on your thread so I thought I would share my solution. Same concept but no client script running. This prevents elements from appearing on the page and then disappearing when the script runs onload.

    define([],
    function() {
    function beforeLoad(scriptContext) {
    if(scriptContext.type!='view' && scriptContext.type!='edit') return;
    var form = scriptContext.form;
    form.addField({type: 'inlinehtml',id:'custpage_bluchat_msgs',label:'msg script'})
    .defaultValue = ' .subtabblock form{display: none !important;} ' +
    '.uir-action-button{display: none !important;} ';
    }
    return {beforeLoad:beforeLoad};
    });

  9. Something I’ve used successfully in client scripts doesn’t require you to set a custom html field.

    function fieldFocus(param) {
    document.getElementsByName(param.id)[0].focus();
    }

    function fieldStyle(param) {
    if (!param) return;
    if (!param.id || !param.style) return;
    var element = document.getElementById(param.id);

    param.style.forEach(function(s){
    element.style.setProperty([s[0]],s[1],s[2]);
    });
    }

    fieldFocus allows you to control where the cursor goes.

    fieldStyle accepts {id: xxxx, style: xxxx} with id being the field/object internal id, while style is an array of normal html styles. I’ve successfully used it to hide elements where they have an id tag set.

    David’s method is also handy, and potentially could execute faster as it’s pre-defining html code, it could also be overridden by html executed from a client script.

    I’ve also used BeforeLoad scripts to preload other libraries such as tabulator.js

  10. Hi Marty,

    I tried this solution, and it’s working as well as sublist line buttons (removed the “Insert” and “Remove” button using this). Can this be done as well to disable the buttons? I tried using the .prop() jQuery API to disable them, but to no avail.

  11. Hi Marty,
    This code worked for me but it shows an empty table coulmn and has colour.. How do I change it.

  12. @Priya, Probably a little late to the party for this but here’s what I did to overcome the left over sub-table and main-table cell that was left behind…

    In my case, I was removing buttons from child record sublists on a custom record… We wanted to hide the “New X” buttons based on certain conditions such as the parent record being in a status of Complete or Cancelled.

    I used the code from Marty and through inspection of the page source I identified what element was holding the button, followed it up to the of the main-table, and I used the below jQuery to hide one element up from the target… I had to do this because the code NetSuite generates for the main table did not name/id the elements…

    scr += ‘jQuery(“#targetElement”).closest(“td”).hide();’;

    So, in the case of whatever element you removed… if there was a table being left behind with no name/id to target, you can just use .closest(“[TAG]”) before .hide() to target it.

  13. Marty,
    I think we could have easily achieved this by using an html type field and write the client js code in it to hide the Buttons .
    Regardless great article and useful blog!!
    Sutha

  14. Hi Marty,
    This works great! Thank you.
    I’ve tried using this on a custom record sublist. (I’m hiding the edit and remove button). It works on the sublist displayed when I first load the record, but it doesn’t worked on the sublist in 2nd or 3rd tab. Do you have any fix for this kind of scenario? Here is my partial code:

    scr += ‘jQuery(“#’ + CDtableId + ‘ tr”).each(function () {‘;
    scr += ‘jQuery(this).find(“td:first, th:first”).hide();’;
    scr += ‘jQuery(this).find(“td:last, th:last”).hide();’;
    scr += ‘});’;

Leave a Reply

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