Prevent editing the fields via List Editor (cell edit) only when the Type is Standard

vivek11
Tera Contributor

Hi Team,

I need script for OnCellEdit client script for below requirement as i dont want to Write ACL for it due to some issues.


Prevent editing the following fields via List Editor (cell edit) only when the Type is Standard:

description

implementation_plan

test_plan (aka "Test and Validation Plans")

backout_plan

Can Someone please help me thanks in Advanced

1 ACCEPTED SOLUTION

@vivek11 

I already shared another option i.e. use before update business rule

But remember this will impact and stop user from saving when fields get updated from form as well.

Any reason not to use list_edit ACL?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

13 REPLIES 13

Community Alums
Not applicable

bro you have to use the client script and scrip include .

https://www.servicenow.com/community/developer-forum/question-about-client-script-oncelledit-script-... 

refer this code  .if your code not working please let me know i will help you to write the code

Ankur Bawiskar
Tera Patron
Tera Patron

@vivek11 

something like this you can check and then enhance for your table, field and values

Example: Don't allow user to select the below state values on incident

Note: Use proper choice values

Example:

6 - Resolved

7 - Closed

9 - On Hold

function onCellEdit(sysIDs, table, oldValues, newValue, callback) {

  var saveAndClose = true;
  if(newValue == '6' || newValue == '7' || newValue == '9'){
  alert('Not allowed');
  saveAndClose = false;
  } else {
  saveAndClose = true;
  }
callback(saveAndClose);

}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi @Ankur Bawiskar 
Thank you for Reply,
I need for Change record, Not on incident could you please help me

Prevent editing the following fields via List Editor (cell edit) only when the Type is Standard:

description

implementation_plan

test_plan (aka "Test and Validation Plans")

backout_plan

@vivek11 

I just shared an example and you can enhance it further based on your requirement and development skills.

Just remember one thing, if you are saying based on some other field value you want to stop editing using onCell edit then it's not possible.

You cannot access other field value in onCell edit client script.

In this case you can use before update business rule and stop the update.

Best is to use list_edit ACL and check the Type value on each of those list edit ACLs for field.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi @Ankur Bawiskar 
I cannot new list_edit ACL as it is affecting existing ACL. Could you please suggest me alternate Solution.

Thank you