How to hide the dropdown of existingrecmachcustrec...
# ask-stanley-ai
a
How to hide the dropdown of existingrecmachcustrecord when storing a record within a sublist of its parent record
c
AI generated answer (using internal Slack threads):
To hide the dropdown of existingrecmachcustrecord when storing a record within a sublist of its parent record, you can use a combination of SuiteScript and client-side scripting. In SuiteScript, you can use the
beforeLoad
event to hide the button. However, it seems that the
form.getButton
method does not work for sublist buttons in SuiteScript 2.0. Here is an example of how you might do this:
Copy code
javascript
function beforeLoad(context) {
    if (context.type !== context.UserEventType.CREATE) {
        return;
    }

    var form = context.form;
    var newButton = form.getButton('newrecrecmachcustrecord_xxxx_cf_contract');
    if (newButton) {
        newButton.isHidden = true;
    }
}
However, as mentioned in the threads, this might not work for sublist buttons. In that case, you can use client-side scripting to hide the button. You can add a hidden field to the form in the
beforeLoad
script, and then use jQuery in a client script to hide the button based on the value of that field. Here is an example:
Copy code
javascript
function beforeLoad(context) {
    var form = context.form;
    form.addField({
        id: 'custpage_hide_button',
        type: serverWidget.FieldType.CHECKBOX,
        label: 'Hide Button'
    }).defaultValue = 'T';
}
Then, in your client script:
Copy code
javascript
function pageInit(context) {
    var hideButton = nlapiGetFieldValue('custpage_hide_button');
    if (hideButton === 'T') {
        jQuery('#newrecrecmachcustrecord_xxxx_cf_contract').hide();
    }
}
Please note that this solution requires jQuery, which is not included in NetSuite by default. You will need to add it to your Suitelet or client script. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.835846364
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.825789273
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.816588938
Please provide your feedback on this answer.