- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-24-2018 11:28 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-24-2018 11:36 AM
onCellEdit is a function that is used in the case of a list. If you want to write some script that should be executed on a list then you can do that by using onCellEdit function.
Here is example for you:
The script below runs on the State field and prevents users from changing the State to closed in a list. Hope this helps.
function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
var saveAndClose = true;
if(newValue == 7){
alert('Not allowed');
saveAndClose = false;
} else {
saveAndClose = true;
}
callback(saveAndClose);
}
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-24-2018 11:34 AM
OnCellEdit Client script is typically used, when you want your client script logic to run, if the user is changing in the list edit view of servicenow.
While onLoad and OnChange used to work on the form layout.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-24-2018 11:36 AM
onCellEdit is a function that is used in the case of a list. If you want to write some script that should be executed on a list then you can do that by using onCellEdit function.
Here is example for you:
The script below runs on the State field and prevents users from changing the State to closed in a list. Hope this helps.
function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
var saveAndClose = true;
if(newValue == 7){
alert('Not allowed');
saveAndClose = false;
} else {
saveAndClose = true;
}
callback(saveAndClose);
}
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2024 02:35 AM
function onCellEdit(sysIDs, table, oldValues, newValue, callback) {