官术网_书友最值得收藏!

onSubmit

The onSubmit client script type runs when a form is saved. This type of script is not that widely used, as we can often use server-side script to perform actions for us once a record is saved, but it can be helpful, as it provides a final chance to execute client-side script before server-side script is run.

The script ServiceNow provides for onSubmit is quite similar to onLoad:

function onSubmit() {
//Type appropriate comment here, and begin script below

}

The onSubmit script type can be used to check field values before a save takes place and abort the save if invalid values exist in fields. 

When considering writing an onSubmit script, it is worth thinking about whether that script could run on the server side instead. This is because the client script runs in front of the user, and further processing must wait until the script finishes, whereas on the server side, the code is executed away from the user and can be executed alongside other scripts.

If you want to abort the form being submitted, return false from the onSubmit function.

We can see an onSubmit example in Figure 3.3:

Figure 3.3: Sample onSubmit client script

For our onSubmit client script example, we can see that this client script is ready for the script to be added for the change table.

主站蜘蛛池模板: 漳州市| 灵武市| 龙南县| 进贤县| 阳信县| 项城市| 永年县| 灵山县| 丹江口市| 连城县| 玉环县| 陵川县| 榆中县| 措美县| 丽水市| 阜城县| 鹤壁市| 绥中县| 云和县| 佛山市| 龙胜| 鄢陵县| 林周县| 馆陶县| 丹阳市| 攀枝花市| 吉林市| 通许县| 宜兰市| 锡林郭勒盟| 渭源县| 依安县| 邵武市| 山丹县| 柯坪县| 永年县| 金川县| 青神县| 绥江县| 四会市| 苍梧县|