
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 03:38 AM
Hi Experts,
I have a requirement to make two variables inactive when a particular checkbox is marked. In achieving this requirement, I have developed a catalog client script. The problem I have is that the catalog client script is not triggering, please help me debbug. I got the configuration and the script below:
Configuration:
Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
// Check the software_licensing field value
if (g_form.getValue('software_licensing') == true) {
alert('software_licensing == true');
// Update mandatory property for hardware and select_request_type fields
g_form.setMandatory('hardware', false);
g_form.setMandatory('select_request_type', false);
}
}
Regards,
Kamva
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 03:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 03:44 AM
Hi @Kamva
You want to make it ianctve or hide? If hide, better to use catalog UI policy which is low code ./ now code.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 03:59 AM
UI policy is the way to go.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 03:59 AM
Hi @Kamva
you need to modify your code:
if (g_form.getValue('software_licensing') == true) {
to
if (g_form.getValue('variables.software_licensing') == true) {
Also you need to keep in mind -
Service portal not support to the variables.var_name
var usr = g_form.getValue('variables.requested_for');
The below onchange client script working fine for my requirement.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
var user = newValue ; // using this i am able to get updated value in that field .
I hope my answer helps you to resolve your issue, please mark correct and helpful accordingly.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 04:36 AM
Hi @Kamva ,
What exactly are you trying to achieve could you please share some screenshot ?
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang