Make Field mandatory using Client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2024 02:16 AM
When Caller is System Administrator then service field become mandatory , Contract field should become hidden and Configuration item should become read only
how to do it using Onchange client script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2024 07:55 PM
Hi @PritanjaliG ,
Yes you need to write Onchange client script.
To achieve that select user is system administrator or not create Client callable Script include and right logic for that return true if the logged in user is system administrator otherwise false.
To call script include in Onchange client script use GlideAjax.
Depending on the answer mark field mandatory or read-only or hide it.
Please mark helpful if my answer resolve you question.
Thanks,
BK

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2024 10:30 PM
Hi there,
What's the reason for asking Client Script? Why not UI Policy instead, zero code involved to what you are asking.
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2024 10:55 PM
Hi @PritanjaliG
Technically it is best practice, to use the OOTB module to avoid the script. The above requirement you can achieve with UI policies like this
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
08-25-2024 01:24 AM
Hello @PritanjaliG ,
you should choose UI Policy for this situation because UI Policy is the better choice in this scenario due to its simplicity, performance, and maintainability. Use a Client Script only if there’s a complex logic that UI Policy cannot handle.
If you found my response helpful, please consider marking it as "Helpful" or "Accept Solution." Thank you!