- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 10:56 PM
Hi All,
I need to remove values from two reference fields, one choice field and one List Collector field based on a choice field selection.
Type of Request : Choice List ( On selection of this field, the below field values needs to be cleared )
Knowledge Base : Reference
Categories : Reference
Role: Choice
Manage Acess: List Collector
I tried using 'OnChange' Catalog Client Script but it isn't working:::
function onChange(control, oldValue, newValue, isLoading) {
// if (isLoading || newValue == '') {
// return;
// }
//Type appropriate comment here, and begin script below
if (isLoading) {
return;
}
if (newValue == "") {
g_form.clearValue('knowledge_base_kb');
g_form.clearValue('categories_kb');
g_form.clearValue('role_kb');
g_form.clearValue('manage_acess_kb');
}
}
Can someone help me in this?
Regards,
Saurabh Chatterjee
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 11:15 PM
Can you check if Ui type is selected ALL & Variable name
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 11:00 PM
Can you try below...!!
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
g_form.clearValue('knowledge_base_kb');
g_form.clearValue('categories_kb');
g_form.clearValue('role_kb');
g_form.clearValue('manage_acess_kb');
}
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 11:05 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 11:15 PM
Can you check if Ui type is selected ALL & Variable name
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 11:12 PM
are you sure the newValue is empty?
Did you add alert and check?
function onChange(control, oldValue, newValue, isLoading) {
//Type appropriate comment here, and begin script below
if (isLoading) {
return;
}
alert(newValue);
if (newValue == "") {
g_form.clearValue('knowledge_base_kb');
g_form.clearValue('categories_kb');
g_form.clearValue('role_kb');
g_form.clearValue('manage_acess_kb');
}
}
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader