- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2022 10:11 PM
Hi All,
We have a requirement to hide "request approval" button on change request form, based on the selection of field "Type" If the type is comprehensive then we need to hide RequestApproval button.
UI action is working only for onload. So I tried using DOM manipulator in client script. but it is trowing some error's. Please let me know, how to achieve this.
Script:
document.getElementById("requestapproval").style.display = 'none';
Error:
Thanks,
Supriya.
Solved! Go to Solution.
- Labels:
-
Change Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2022 08:57 AM
Hi,
try this in the onChange client script of Type field
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (newValue == 'comprehensive') {
var items = $$('BUTTON').each(function(item) {
if (item.innerHTML.indexOf('Request Approval') > -1) {
item.show();
}
});
}
else {
var itemss = $$('BUTTON').each(function(item) {
if (item.innerHTML.indexOf('Request Approval') > -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-01-2022 09:50 PM
Hi,
Cannot be achieved without using DOM
Isolate Script checkbox for that UI action should be False
If this field is not on form then from list you can mark it False
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-03-2022 03:04 AM
Hi Ankur,
The lsolate script check box for that UI action is false. still I'm facing the same error. Please let me know how to proceed.
Thanks,
Supriya.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2022 08:57 AM
Hi,
try this in the onChange client script of Type field
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (newValue == 'comprehensive') {
var items = $$('BUTTON').each(function(item) {
if (item.innerHTML.indexOf('Request Approval') > -1) {
item.show();
}
});
}
else {
var itemss = $$('BUTTON').each(function(item) {
if (item.innerHTML.indexOf('Request Approval') > -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-07-2022 11:27 PM
Hi,
It is working.
Thanks,
Supriya.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2022 11:36 PM
Glad to help.
Please mark response helpful as well.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader