
- 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:41 AM
Hi Harel - I received the following error using your code
function onChange(){
var state = g_form.getValue('state');
if(state == '-940' || state == '-941' || state == '-942' || state == '-943'){
$$('#task_completed')[0].hide();
} else {
$$('#task_completed')[0].show();
} }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2017 01:09 PM
Hi Edwin,
I think you are missing a part of the script.
Try:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var state = g_form.getValue('state');
if(state == '-940' || state == '-941' || state == '-942' || state == '-943'){
$$('#task_completed')[0].hide();
} else {
$$('#task_completed')[0].show();
}
}
I tested it on my incident form and it seems to work without a hitch.
If it is still a problem, where are you applying it on? Is it a custom form?
harel

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2017 09:37 AM
Still receiving the error and yes the update applies to a custom form within a scoped app
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2017 09:45 AM
OK.
See this: Scoped Applications and Client Scripts: A Primer
$$ is inaccessible in scoped apps. Read through the part What are the differences between a scoped Client Script and a global one?
- I think it might have a solution for you.
harel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2017 11:07 AM
Hey Edwin,
You can better do this on the condition part of the button itself.
like : (current.state != "-940") || (current.state != "-941") and so on.
post me your feedback
Please Hit ✅Correct, â�ï¸�Helpful, or â�£ï¸�Like depending on the impact of the response
Have a lovely day ahead
Regards,
Divya Mishra