Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

How to Dynamically Show/Hide and Make a Field Mandatory Based on Another Field in ServiceNow

msekla
Tera Contributor

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:

  1. When users select a Configuration Item that requires a URL, a URL field should appear under Configuration Item.
  2. The URL field should be required if the selected Configuration Item needs a URL.
  3. 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?
2 REPLIES 2

Ademir Amaral1
Kilo Sage

@msekla 

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.

Tosin D
Kilo Sage

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.