How to make a list column read-only based on another field using onCellEdit?Body:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @AbW
Please refer the below thread i hope it will work for you!
https://www.servicenow.com/community/developer-blog/learn-servicenow-oncelledit-client-script-servic...
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Thank You
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
you can use before update BR and validate this and abort the update
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @AbW
Can you try this once - onCellEdit on state field. For me first choice is always ACL here.
function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
var saveAndClose = true;
var gr = new GlideRecord('incident');
gr.addQuery('sys_id', 'IN', sysIDs);
gr.addQuery('category', 'inquiry');
gr.query();
if (gr.hasNext()) {
alert("State cannot be changed from the list view for Inquiry / Help records.");
saveAndClose = false;
}
callback(saveAndClose);
}
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
try this
On cell edit on state
client script :