Need to make all the fields on a form read-only except for one.

David Yearsley
Tera Expert

Having a problem with setting the fields on a form to read-only, except for one. If you can set all fields to read-only you can do it with an ACL. But If you set and ACL to set the fields to read-only and then have an ACL to allow the one field to be written to, the first ACL, prevents the second ACL from setting the one field back to Writable.

This could be done in a data policy but there a many fields and it would be a long list to set the fields to read-only and then every time you added a new field you would have to update the Data Policy.

Thanks

1 ACCEPTED SOLUTION

bernyalvarado
Mega Sage

Hi Dave,



This could be managed through ACLs on the following way:



a) Have a write ACL at the table.* level that will lock all fields


b) Have a write ACL at the table.field level that will grant access to the specific field.



The table.field ACL will take precedence over the table.* ACL.



Thanks,


Berny


View solution in original post

3 REPLIES 3

bernyalvarado
Mega Sage

Hi Dave,



This could be managed through ACLs on the following way:



a) Have a write ACL at the table.* level that will lock all fields


b) Have a write ACL at the table.field level that will grant access to the specific field.



The table.field ACL will take precedence over the table.* ACL.



Thanks,


Berny


One additional note, make sure that any write ACL at the table level is not restricted. So for instance, if the table you're using is incident, then the ACL at the table level is going to be called: incident and that should not lock access unless you want to fully lock access to someone and-or under a given condition.


Jatin Ponnaluri
ServiceNow Employee
ServiceNow Employee

Hi @David Yearsley  ,


Let us take a scenario where only one field is editable are the rest are read-only for the role "agent"

  1. Row-level ACLs are combined with the logical OR
  2. Field-level ACLs are combined with the logical OR
  3. The results of 1 &2 will be combined with the logical AND

    You might require 2, or 3 ACLs in a few cases, 
    i.  A field level tablename.* write operation ACL with requires role "nobody".  Which means nobody can edit all the fields.
    ii. A field level table.yourField write operation ACL with require roles "agent".  Which means only the desired role (in our case agent) can edit the field mentioned. 

    Now opening any of the above created ACL,  click Show ACL Execution Plan and check if any pre-existing row level ACL is present which might disrupt our scenario, if yes, ( In my case I had one default ACL which required admin role to pass) .. then, you might need another ACL as mentioned below.
    iii. create a row level  write operation ACL with require roles "agent". Which means users with role agent can write. 

    It evaluates to iii && (i || ii).

    Thanks,
    Jatin