How to Show/Hide URL Field When Required

msekla
Tera Contributor

I currently have a hidden URL field made and I want it to appear in my Generic Request form once I select a Configuration Item that has a specific URL value I put in the CMDB.

If the chosen Configuration Item has the "URL required" field set to "yes" on the CI listing, then:
1. Show the "URL" field on the Generic Request form (i.e. make it visible)
2. Make the "URL" field mandatory on the Generic Request form

 

I have attached a snippet of what I have so far and I don't know why it's not working as in when I select a Configuration Item that has the URL value that I put in the CMDB, that the script looks for, it should then make the URL field appear on my form and make it mandatory.

Please help and let me know what I should do in detail. Thank you.

1 ACCEPTED SOLUTION

@msekla , it might be because of setVisible so try replace this with setDisplay() 

 

g_form.setDisplay('url',true);

 

replace in both if and else if 

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

 

View solution in original post

26 REPLIES 26

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @msekla 

 

Try with 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]

****************************************************************************************************************

How would I do it exactly? can you give me a step-by-step guide or a screenshot of the final product of a Catalog UI Policy that actually does the task I want done?

swathisarang98
Giga Sage
Giga Sage

Hi @msekla ,

 

You should not write GlideRecord in Client side which will effect in instance performance, so use GlideAjax and write a script include(si) call the SI in your catalog client script through this you can achieve your requirement.

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

I have tried what you told me and it's still not working, can you please write me a script that would satisfy what I want done. It is not letting me attach what I wrote using GlideAjax for some reason.