- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2022 02:59 AM
Hi everyone,
My requirement is to show and hide UI action based on change of field on form . Form that I have created on change client script but it is not working properly . Can anyone please help me.
And my UI action:
Thanks in advance
cc:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if(value == ''){
var items = $$('CareAR Instruct').each(function(item){
if(item.innerHTML.indexOf('CareAR Instruct') > -1){
item.hide();
}
});
}
else if(value != ''){
var model = $$('CareAR Instruct').each(function(item){
if(item.innerHTML.indexOf('CareAR Instruct') > -1){
item.show();
}
});
}
//Type appropriate comment here, and begin script below
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2022 07:37 AM
Hi,
update as this -> give label of that button
I hope you have done this already
please make Isolate Script as False for your Client Script
If this field is not on form then from list make it false
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var val = g_form.getValue('x_care3_carear_fsm_instruct_experience');
if (val != '') {
var items = $$('BUTTON').each(function(item) {
if (item.innerHTML.indexOf('CarearInstructButton') > -1) {
item.show();
}
});
}
else {
var itemss = $$('BUTTON').each(function(item) {
if (item.innerHTML.indexOf('CarearInstructButton') > -1) {
item.hide();
}
});
}
//Type appropriate comment here, and begin script below
}
regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2022 03:09 AM
Hello,
DOM manipulation is not recommended in Servicenow so I suggest you control visibility through UI action condition and make it work on load of form. This is what Servicenow recommends and UI visibility can be controlled when form loads and not when something changes on form.
Please hit like and mark my response as correct if that helps
Regards
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2022 03:11 AM
Hi
My requirement is to get it in change rather than onload.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2022 03:16 AM
I understand but DOM manipulation is not recommended but if you still insist go through below threads, Make sure 'Isolate script' checkbox is set to false
https://community.servicenow.com/community?id=community_question&sys_id=3cf172b8dbe3841413b5fb2439961926
https://community.servicenow.com/community?id=community_blog&sys_id=127d6269dbd0dbc01dcaf3231f961973
https://community.servicenow.com/community?id=community_question&sys_id=2cf54361db1cdbc01dcaf3231f96193c
https://community.servicenow.com/community?id=community_question&sys_id=c0a14ecddbcc58d8d82ffb2439961915
Regards
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2022 05:43 AM
Hi,
please make Isolate Script as False for your Client Script
If this field is not on form then from list make it false
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader