- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2023 01:59 AM
I have a variable "Action Required" which has two options: Add and Remove.
The requirement is: When we select Add, Option "New website access for CUI secure transfer" should be visible. And when we select Remove, that option should not be visible.
I wrote a client script, but When I am selecting Add, the option is showing.
When I am selecting Remove, The option is not showing.
But again when I am selecting Add, the option is still not showing unless I refresh the page. Kindly let me know how to fix this issue. Thanks.
Field Name: Type of Request
Backend value: dependent_field_1
I wrote the below OnChange Client Script:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2023 02:12 AM
can you try below script:
function onChange(control, oldValue, newValue, isLoading)
{
if (isLoading || newValue == '')
{
return;
}
if(newValue=="1"){
g_form.addOption('dependent_field_1','New website access for CUI secure transfer',"New website access for CUI secure transfer");
}
else
{
g_form.removeOption('dependent_field_1','New website access for CUI secure transfer');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2023 02:29 AM
Thank you so much. This worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2023 02:16 AM
you should use choice value during remove option
try this
function onChange(control, oldValue, newValue, isLoading)
{
if (isLoading)
return;
if(newValue == '1')
g_form.addOption('dependent_field_1','New website access for CUI secure transfer');
else
g_form.removeOption('dependent_field_1','New website access for CUI secure transfer');
}
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2023 02:27 AM
Same issue, When I am selecting Add, the option is showing.
When I am selecting Remove, The option is not showing.
But again when I am selecting Add, the option is not showing unless I refresh the page.