Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

field non editable

zx
Tera Contributor
How to make the value of the field on the list also become non editable when the field on the screen is non editable?
3 REPLIES 3

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @zx 

 

You can do via client script type = Oncelledit

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

HIROSHI SATOH
Mega Sage

I think the OOTB approach would be to:

- Set the field to read-only

- Control updating of the field with ACL

Badrinarayan
Tera Guru

 

Hi @zx ,

Making a Field Read-Only in the Form View

  1. Using the Dictionary Entry:

    • Right-click on the field label.
    • Choose Configure Dictionary.
    • In the dictionary entry, check the Read-Only option to make the field always read-only on the form.
  2. Using UI Policies (for Conditional Read-Only):

    • If the field should only be read-only under certain conditions (e.g., based on a user role or value in another field), you can use a UI Policy.
    • Navigate to UI Policies and create a new policy.
    • Set your condition (e.g., based on the value of another field).
    • Under UI Policy Actions, choose the field and set Read-Only to True.

Making a Field Read-Only in the List View

There are two methods to achieve this:

  1. Using Access Control:

    • Access controls (ACLs) are used to control permissions for who can read, write, or delete records and fields.
    • Navigate to System Security > Access Controls.
    • Find or create an access control for incident.field_name.
    • In Advanced View, set the script as answer = false; to prevent editing of the field in the list view for all users except those with explicit permissions.
  2. Using an onCellEdit Client Script:

    • This client script type can prevent users from editing specific fields in list view.
    • Navigate to System Definition > Client Scripts, and create a new client script.

Set the Type to onCellEdit.Screenshot 2024-09-20 at 3.14.02 PM.png

 

function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
  var saveAndClose =true;
 //Type appropriate comment here, and begin script below
 saveAndClose =false;
 callback(saveAndClose); 
}​

 

If You Feel that Your Issue is Resolved , Please Mark it as Helpful and Accept The Solution 

 

Thanks Regards

Badrinarayan