- Mastering ServiceNow Scripting
- Andrew Kindred
- 381字
- 2021-06-24 19:08:41
onCellEdit
The onCellEdit type of client script runs when a cell is edited on the list view of a table. This is the only client script type that does not run on the form view of a table. This type of client script is helpful to ensure that the rules you want to stick to are also enforced on list views of a table.
The script that ServiceNow provides for onCellEdit scripts looks a little different from the other client script types:
function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
var saveAndClose = true;
//Type appropriate comment here, and begin script below
callback(saveAndClose);
}
It is worth noting that these scripts could be for multiple records, as you can edit more than one using a list. As you can see, there are quite a few different parameters in this slightly different type of script. We'll have a look at what each one of those parameters gives us:
- sysIDs: All of the sys_id unique IDs of the records being edited in an array.
- table: The current table of the records being edited.
- oldValues: The old values of all the cells being edited.
- newValue: The new value to be put into all the cells being edited.
- callback: A callback that allows the execution of further onCellEdit scripts or commits the change made if no further scripts exist. A true or false parameter can be passed, which will either allow further scripts and commit changes, or stop execution of further scripts and not commit the change, respectively.
These scripts tend to not be used that frequently, as server-side scripts like business rules can often be used to perform the functionality needed. Editing records in the list can also be a powerful tool for updating multiple records at once, so this is sometimes locked down to only certain users to prevent less knowledgeable users from causing issues.
An onCellEdit client script example can be viewed in Figure 3.4:

The client script in the preceding figure is an onCellEdit for the requested item table. Again, for this type of script, ensure the Field name field is set to the value you require, as the script will only run on a change to this field in the list view.
- 面向STEM的mBlock智能機器人創新課程
- 工業機器人產品應用實戰
- Natural Language Processing Fundamentals
- Dreamweaver CS3網頁制作融會貫通
- 四向穿梭式自動化密集倉儲系統的設計與控制
- JSP從入門到精通
- RedHat Linux用戶基礎
- 基于Proteus的單片機應用技術
- Linux Shell Scripting Cookbook(Third Edition)
- 步步驚“芯”
- Natural Language Processing and Computational Linguistics
- 工業機器人操作
- FreeCAD [How-to]
- Learning iOS 8 for Enterprise
- 數據庫基礎:Access