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

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.

主站蜘蛛池模板: 攀枝花市| 弥渡县| 钟祥市| 大冶市| 鹿泉市| 织金县| 长春市| 淄博市| 全椒县| 丘北县| 拉孜县| 灵石县| 丰镇市| 南平市| 亳州市| 谷城县| 鹤山市| 郧西县| 武邑县| 二连浩特市| 天门市| 铜梁县| 永登县| 凌源市| 鄂托克前旗| 永嘉县| 杨浦区| 新巴尔虎左旗| 四子王旗| 延川县| 商城县| 宁城县| 武冈市| 苏尼特右旗| 潼南县| 左云县| 松滋市| 新晃| 托里县| 星子县| 嘉黎县|