How to make a field readonly on a form if a template is applied

szollo
Kilo Contributor

Hello,

I have a custom reference field on a Change form, called Template. That field references System Definition->Templates. If I select a template, then some fields are populated on the form.

This all works fine, however I'd like to achieve that as soon as a field is populated(due to the selection of the template) make it read-only, not editable.

I've tried several options(client scripts, business rule, ACL, etc.), but none of them working as expected, although I'm new to ServiceNow, so it could be I was not doing it the right way.

Those fields that are populated due to the template can also be read-only by default, however when I was unable to achieve that(tried using ACLs, but I've found that read-only fields were not populated when I selected a template).

I need to make sure that as soon as a template is selected, the values that is populated on the form are not editable. I want to achieve this dynamically(without Saving the form).

Could you please give me some guidance on how to achieve this?

1 ACCEPTED SOLUTION

Right off my mind I would turn to ui polices. Not sure if you need to make 1 ui policy for each field or you can make only one with some fancy condition, haven't thought to so much on it. It's pretty much to choose from a few simple ones or one complicated one.



But it should work if you have a UI policy with condition that if field template isn't empty and field b(which the template fills) isn't empty, then read only sets on field B.



Shouldn't that work?



//Göran


View solution in original post

11 REPLIES 11

Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

In Geneva there is "Standard Change Catalog". It does pretty much what you asking for here. Perhaps that is your solution?



Btw. If you upgraded to Geneva this plugin isnt active by default.



Can read more about it here: https://docs.servicenow.com/bundle/geneva-it-service-management/page/product/change_management/conce...


Hi Goran,



This is exactly what we need, but unfortunately - I forgot to mention - we are on Fuji, so this solution will not work for us.


Basically we would like to use Templates as Standard Changes, that's why the fields cannot be modified once the template is applied.



While this option is interesting and new to me, I'm still trying to find a solution for our case. Are you aware of any alternative solution that could be used in this case?



Best regards,


Gergely


Right off my mind I would turn to ui polices. Not sure if you need to make 1 ui policy for each field or you can make only one with some fancy condition, haven't thought to so much on it. It's pretty much to choose from a few simple ones or one complicated one.



But it should work if you have a UI policy with condition that if field template isn't empty and field b(which the template fills) isn't empty, then read only sets on field B.



Shouldn't that work?



//Göran


Hi Goran,



Thank you very much, that worked!



Unfortunately this brought up an issue where making HTML field to read-only causing the field disappearing(keeping only the label and the +- chars to increase/decrease the size of the box), but that's a different issue.



Thank you again!