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

jmcagod
Kilo Guru

Hi Gergely,



Were you able to figure out how to make it as read-only? Can you share what you did to make it RO? Thanks



I followed the steps to create a UI Policy and got lost in setting condition "Template is not empty".


szollo
Kilo Contributor

Hi,



I've created the UI Policy on Change Request table and set the condition like the following:


find_real_file.png


After this in the UI Policy Actions I configured the required field read-only:


find_real_file.png



The Template field is a custom Reference type field with the following settings:


find_real_file.png



I hope this helps,


Gergo