Onchange client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2023 06:19 AM
I have written the below onchange client script to make Subcategory mandatory when the Category is Software but it is not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2023 06:22 AM
Hi @GBS
Create UI Policy
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
12-19-2023 06:24 AM
Thanks for the response, but I want to achieve it by script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2023 06:30 AM
Hi @GBS
Description
When client script is used to make a field not mandatory, the field is instead made mandatory.
Steps to Reproduce
- Create a client script to make the Short Description field of a change request NOT mandatory.
An example client script is attached to this article. - Open a change request record.
Note that the Short Description field does not appear to be mandatory. - Clear the Short Description field and try to save the record.
A warning is displayed stating that the short description is mandatory and the record cannot be saved.
Workaround
Work around the issue by setting your script to use a boolean argument rather than a string:
Before: g_form.setMandatory(field, 'false')
After: g_form.setMandatory(field, false);
Related Problem: PRB706263
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
12-19-2023 06:34 AM
Hi @GBS
Syntax:
g_form.setMandatory('fieldname',true); // To make mandatory
g_form.setMandatoy('fieldname',false); //to make non-mandatory
g_form.setReadOnly('fieldname',true); // To make Readonly
g_form.setReadOnly('fieldname',false); //to make non-readonly
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]
****************************************************************************************************************