I have created some buttons in a suitelet. Now I w...
# suitescript
r
I have created some buttons in a suitelet. Now I wane to hide/show them based on some condition in clientScript pageInit Can someone provide me a small code for it, in case it's possible.
n
Copy code
const customButton = document.querySelector('custpage_button');
customButton.style.display = 'none';
This kind of works. If nothing else it might give you a good starting point
Theres got to be a better way.
Copy code
const currentRec = currentRecord.get();
const button = currentRec.getField({ fieldId: 'custpage_hide' });
button.isDisabled = true;
Ehh this is better. It grey's out the button and doesn't allow it to be clicked
c
if you're doing this in pageInit then there is no client interaction so you should just be able to do the logic when you create the form. If you're trying to show/hide buttons based on client side input, then disabling would be alright.
r
Thank you @Nathan L I could do it in suitelet as well, but the architecture of the module was built in such a way that doing some part in suitelet and the rest half in the client will make it more complex to understand in future. Both disabling and hiding worked. Went with disabling the buttons as it looks more user friendly.
🫡 1
n
A note on this, if you try and modify the style display properties you probably need to inspect the button and look at the outer element's id it'll likely be in a div / span and possibly include a separator symbol in the UI if there are several buttons next to each other. I have done this a few times, and it always makes me flinch, it's a bit of a "hack" imho. If you literally just hide the button directly by the NS internal id it can leave messy html artefacts.
n
I noticed that when I tried using the style.display thing. It like removed the button but leaves the container and creates this awkward blank space
💯 1
r
Another question on this, I am able to disable the button at the top of the screen, but not at the bottom. I noticed while inspecting the page, Netuite adds the keyword secondary to the buttons at the bottom. so custpage_x becomes secondarycustpage_x. But I am unable to disable it.
@Nathan L do you have any knowledge on the above ?