The CreatorCon Call for Content is officially open! Get started here.

Read only UI Policy not working

cre1014
Kilo Expert

I'm having trouble diagnosing why my UI Policies no longer work; I have created a custom form with custom buttons that update the stage located on form when selected. The stages that I have so far are "Define", "Design", and "Transition". All of the fields associated with each stage should not be editable when the form is in a different stage, and thus we have to make them read only.

The problem I'm having is that the fields linked with "Define" and "Design" are editable whenever the form is in either stage; however, when the form is in the "Transition" stage everything linked with "Define" and "Design" is read only as expected. All of these UI Policies are set up the same way and I can't figure out why two of them won't work when the last one does. I have disabled all associated client scripts on this table and other UI Policies on this table making fields mandatory, and I still have the same issues.

Out of curiosity, I set the UI Policies to hide the variables that are supposed to be read only on certain stages; the UI Policy successfully hides these fields. I checked the console log to see if anything was being tripped up and found that my condition for the UI Policies was being triggered and that the console log says that the fields are being set to read only... obviously that's not happening.

Is there any other area that I'm missing that may be causing the issue?

1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Hi Caitlyn,



I would recommend the following for making fields read only:


1. ACLs - Access controls are great because they run on the server and apply to both forms and lists. However, if you need the mark something read only based on a change on the form, they won't work.


2. UI Policies - These are nice because they require no scripting and you can order them. They also support pretty complex conditions, but they only really work for a condition or the opposite of that condition, so if you have a number of different conditions that have more than 2 outcomes, you might need to use a client script.


3. CS are all scripting so they can be more difficult to work with, but they can do everything a ui policy can do and more.



From your description it sounds like you might still be able to use a ui policy. Could you do something like:



Condition: Stage is 1 or 2


Action: Field is read only



And just separate it out in its own ui policy.


View solution in original post

16 REPLIES 16

Pradeep,



There isn't, I've checked. 😕



I'm wondering if how I've set up the UI policy has anything to do with it; the third UI policy I discovered is what was breaking the first two because it set fields to be read only twice.


Are all the ui policies running Onload? means have you checked the "Onload" check box?



Check this - Multiple UI Policies on the same field



Thanks,


Ganesh


Brad Tilton
ServiceNow Employee
ServiceNow Employee

So you have multiple ui policies acting against the same field? It's not recommended to do that because it's pretty easy to end up with conflicting policies when they all have different conditions and are set to reverse if false. There are some circumstances where the conditions are advanced enough to where you have to use a client script instead of ui policies. Could you post screenshots of the 3 policies and their actions?


Brad,



I think that's my issue: right now, I have them set up to lock the fields based on what the stage IS. This means that there are multiple policies that are locking down the same fields multiple times. What I'm trying this time to set the fields to lock all the time except when they need to be editable based on their related stage. As it's not set up that way right now I don't have screenshots, but I'll let you know how it goes.



What would you recommend instead of UI Policies for intricate situations?


Brad Tilton
ServiceNow Employee
ServiceNow Employee

Hi Caitlyn,



I would recommend the following for making fields read only:


1. ACLs - Access controls are great because they run on the server and apply to both forms and lists. However, if you need the mark something read only based on a change on the form, they won't work.


2. UI Policies - These are nice because they require no scripting and you can order them. They also support pretty complex conditions, but they only really work for a condition or the opposite of that condition, so if you have a number of different conditions that have more than 2 outcomes, you might need to use a client script.


3. CS are all scripting so they can be more difficult to work with, but they can do everything a ui policy can do and more.



From your description it sounds like you might still be able to use a ui policy. Could you do something like:



Condition: Stage is 1 or 2


Action: Field is read only



And just separate it out in its own ui policy.