How to Hide a Field using a UI POlicy

Nilanjan1
Mega Sage

Hello All, 

Request your help, I have created a form but I would like to hide a few fields and only make it visible when selecting a certain selection, can this be done through a UI policy, If yes, how?

Regards

1 ACCEPTED SOLUTION

Gaurav Shirsat
Mega Sage

Hi Nilanjan

Happy that You got the Answer by our references.

It is always a Best Practice, when you are perform the activity at client side,always first check whether you can achieve your goal by configuration or not.?

UI Policy always better in this case but still if you are looking for additional functionality then go for Client Script.

These are some useful benefits of both:-

1)Both runs on users browser where we have JavaScript run engine.

2)UI Policies Runs after Client Script but in terms of Execution the UI Policies are Faster because of NO Scripting involved.

3)also you can run client scripts in UI Policies.

4)Client Scripts gives you the Chance for out of the box solution scripting facilities.

 

Please Mark Correct and Helpful

Thanks and Regards

Gaurav Shirsat

View solution in original post

6 REPLIES 6

Jaspal Singh
Mega Patron
Mega Patron

Yes, Nilanjan this can be accomplished by UI Policy as well as Client Script. Prefer UI Policy as it would be code free.

You can follow link for the same as it has an example that you can relate & get it created.

Akash Gurram1
Giga Guru

Hi Nilanjan,

You can use UI policy to achieve this. 
First create a UI policy and give your conditions in the When to Apply field.


Once you create the UI Policy, Create a new UI Policy action in the Related Lists. Here you can specify the field that you want to hide and select visible to be False.

That should work.

Gaurav Shirsat
Mega Sage

Hi Nilanjan

Please follow the Video to achieve your Target:-Follow the Procedure given in below video and perform simultaneously on your Personal Developer Instance.

https://www.google.com/search?q=how+to+hide+the+field+of+form+using+UI+Policy+in+servicenow&oq=how+t...

If you need additional information of each field,please go through this servicenow DOCS:-

https://docs.servicenow.com/bundle/orlando-platform-administration/page/administer/form-administrati...

also you can achieve your target by using the Scripts but it's better to use UI Policy.

Please Mark Correct and Helpful

Thanks and Regards

Gaurav Shirsat

Nilanjan1
Mega Sage

Thank you so much for the quick reply I was able to create the UI Policy, unfortunately I am unable to hide the fields. The logic works this way. 

If I select a type as and Parent group as  "X1 & X2 " the following three fields would populate "L1, L2 & L3" . I have put in the condition when to run as when the user selects the X1 and X2 group, the following fields L1, L2 & L3 would be populated otherwise it would remain hidden. Inpite of the conditions provided the fields are not getting hidden in the form . Can some one please advise. Attached screenshots for clarity. 

 

Regards