
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2017 08:10 AM
I have the below script that is currently not working. I need to hide the "Complete Task" button if the state changes to any of the following. "-940", "-941", "-942", "-943". Can someone help me correct this script?
function onChange(){
//If the incident type is 1,2,3
}
showCloseTaskButton('Convert to Request');
function showCloseTaskButton(button) {
if(g_form.getValue('state' == -940) || g_form.getValue('state' == -941 || g_form.getValue('state' == -942) || g_form.getValue('state' == -943)){
//show the 'Convert to Request'
var items = $$('BUTTON').each(function(item){
if(item.innerHTML.indexOf('Complete Task') > -1){
item.show();
}
});
} }
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2017 01:55 AM
Hi Edwin,
if you want to make your ui action visibility based on dropdown values then you can try with UI Policy.
refer the screenshot below. i tested with category values. button will be visible based on category values.
Script :
function onCondition() {
$$('#awc_test')[0].show();
}
******************
function onCondition() {
$$('#awc_test')[0].hide();
}
Hope it will help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2017 08:18 AM
Is the requirement to not show the button if the form is already in one of your closed states or to actively hide it if they change the state using the state field on the form? If the former, add a condition to the button to hide it. If the latter, I believe the "indexOf" should search for the action name instead of the displayed name of the button.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2017 08:22 AM
The requirement is to actively hide the button once a user selects the state of "-940", "-941", "-942", "-943" using the state field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2017 08:54 AM
Ok, ensure that your UI Action has the field "Action Name" populated with a value. Then update your script
function onChange(){
//If the incident type is 1,2,3
}
showCloseTaskButton('Convert to Request');
function showCloseTaskButton(button) {
if(g_form.getValue('state' == -940) || g_form.getValue('state' == -941 || g_form.getValue('state' == -942) || g_form.getValue('state' == -943)){
//show the 'Convert to Request'
var items = $$('BUTTON').each(function(item){
if(item.innerHTML.indexOf('action_name_you_gave_it') > -1){
item.show();
}
});
} }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2017 08:20 AM
Hi Edwin,
Your ui actions you can have an action name, so if for instance you have a button with action name "testme" you can have an onChange client script with:
var state = g_form.getValue('state');
if(state == '-940' || state == '-941' || state == '-942' || state == '-943'){
$$('#testme')[0].hide();
} else {
$$('#testme')[0].show();
}
if you have the button at the top and bottom of the page, add lines with [1] as well
harel