How to Dynamically Show/Hide and Make a Field Mandatory Based on Another Field in ServiceNow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2024 11:18 AM
I'm currently customizing the Generic Request form in ServiceNow, and I need assistance with dynamically showing/hiding and making a field mandatory based on another field's value. In the Generic Request form, users select a Configuration Item from a dropdown list. Depending on the selected Configuration Item, I want to dynamically show or hide a URL field and make it mandatory if the Configuration Item requires a URL.
Here are the specific requirements:
- When users select a Configuration Item that requires a URL, a URL field should appear under Configuration Item.
- The URL field should be required if the selected Configuration Item needs a URL.
- Conversely, if the Configuration Item selected does not require a URL, the URL field should remain hidden.
Could someone guide me on how to achieve this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2024 11:24 AM - edited ‎02-22-2024 11:24 AM
You can do this using UI Policy or Client Script
Here's a tip on how to use the client script in onchage:
https://www.youtube.com/watch?v=8P3tVfim5HQ
And here at UI Policy:
https://www.youtube.com/watch?v=NFo85egmhRs&pp=ygUebWFuZGF0b3J5IFVJIHBvbGljeSBzZXJ2aWNlbm93
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2024 11:26 AM - edited ‎02-22-2024 11:27 AM
I would suggest using a UI Policy for this. Check this article https://www.servicenow.com/community/developer-articles/ui-policies/ta-p/2831805
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.