- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2015 03:47 PM
I need onchange client script to enable /disable button based on state.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
// var state = g_form.getValue('state');
if(newValue== 11 ){
var items = $$('BUTTON').each(function(item){
if(item.innerHTML.indexOf('Submit') > -1){
item.hide();
}
});
}
else{
var _items = $$('BUTTON').each(function(item){
item.innerHTML.indexOf('Submit').show();
});
}
}
It fails the behavior.
Thanks
Solved! Go to Solution.
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2015 07:13 AM
I didnt realize your show logic is flawed...
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
// var state = g_form.getValue('state');
if(newValue== 11 ){
var item = $$('BUTTON').each(function(item){
if(item.innerHTML.indexOf('Submit') > -1){
item.hide();
}
});
}
else{
var _item = $$('BUTTON').each(function(_item){
if(_item.innerHTML.indexOf('Submit') > -1){
_item.show();
}
});
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2015 06:58 AM
Just a question.
Why do you need to hide it using a onchange script ? Can't you make use of condition field in UI action and show/hide it ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2015 07:02 AM
Here hiding is based on state(choice list). UI action will hide permanently.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2015 07:07 AM
So it's like once the state is changed, button should not be available. How is that different from using the condition field?
Logically speaking, if you change the state on the form, that doesn't mean the state of the ticket is changed at the table/database level. Are you sure of the requirement that you need to hide the button on onchange of state and not the actual change of state?
I would recommend you to clarify this before you start implementing. Frankly speaking, these custom scripts will give you more headache's during instance upgrades. I would not go this route unless it is absolutely necessary and clients are not agreeing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2015 07:14 AM
Is there any other way.
My requirement - Add new field "InQueue" to state choice list for change ticket.
When user select InQueue -- Form button must be disappear so that the change ticket will not move forward.
if they select other state - change ticket will move forward.
I tried UI Action --> but it want reflect when we change choice list.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2015 10:27 PM
Hello Kalairasan,
Have a question around the same hide/show button. I have a requirement where in I have to implement a custom Submit button (Got to implement a custom client script specific to my change request form), but the out of the box global 'Submit' button is also getting displayed on the change form in addition to the custom Submit UI action I just created. Do you recommend an alternative solution to get rid of the out of the box 'Submit' buttom than the below piece of onload() script to hide the button?