Hi all! Anyone knows how to make a disabled button...
# suitescript
d
Hi all! Anyone knows how to make a disabled button enabled in the client script? I tried the following code:
Copy code
const button = document.getElementById('custpage_po_update_button');
button.removeAttribute('disabled');
'disabled' attribute is removed after that, but the button stays inactive
s
i'd say use var instead of const, but for me you'd need to show more to see (what code it is in what script type... etc... to give a better verdict
👎 2
d
This is a client script, pageInit function
s
unless there is special reasons, when you spawn the button in, you should be able to specify the display type there too... instead of acting on this method called DOM, which is... not really a supported method of NS
d
I thought so, yes, but didn't find a right way to get the button by its id
So, in the UserEvent script I am creating this button:
Copy code
const poUpdateButton = itemSublist.addButton({
    id: 'custpage_po_update_button',
    label: 'PO Update',
    functionName: 'some',
});
s
ok in that case i need to ask you whether or not the button is disabled on the fly after the page is loaded?
d
It is disabled by the default.
So in the client script I check couple conditions and if the requirements are met, I want to enable the button
The problem is how to get the reference to that button
s
i think battk will need to answer to this question, but i dont think what your saying is do-able as a sublist button
i know if it's it's clickable, but it respond an error message when its not supposed to be clicked is ok
but I dont think reactivating the button when it's already disabled is something do-able
as a sublist button
my thought process now of what i know is do-able is it uses the client script, prompt windows, block or not block based on the fields, thats do-able
from what i know, as far as the sublist is loaded, that's how it is, so, you might need someone better with sublist to tell you about that
d
Ok, @Sciuridae54696d thank you!
s
I think the crux is if you do need to button to be disabled, if you will allow it to be stil enabled, but not passed through, i'm faily sure that would be do-able, anyway
apologies @Dmitry Masanov
d
Well, I think i still can hide the button completely
s
i'd say unless purely on dom, I dont think it can then appear and then allow it to do what you want to?
it's outside my breadth so i apologise
d
Well, moreover, maybe it's ok when user clicks the button even if the requirements are not met yet. Will just show him a warning.
s
I've been liking to explore towards N/ui/message for those instead of N/ui/message or alert(); I think they personally feel quite professional, when compared to no messages at all
c
What does the button do? If updating a related record or current record, you can always move it to a UE script if its just updating and not have a button at all.
d
Yes, it's updating the related records, but user chooses the way to update them
c
You could make a checkbox or a dropdown and work off of that too
manipulating the dom is gonna result in a bad time.
b
i believe that dom manipulations are the only choice for button control in client script
I would compare a disabled button to a normal button to see what you have to do
I would expect you to need to modify the style of the button, which is very much netsuite dom related