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

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.

主站蜘蛛池模板: 绥宁县| 桐城市| 获嘉县| 长乐市| 三门峡市| 克东县| 淳化县| 南部县| 牟定县| 武夷山市| 荆州市| 岳池县| 绥棱县| 湘西| 通城县| 石景山区| 凭祥市| 读书| 宁化县| 安塞县| 伊宁县| 法库县| 祁门县| 县级市| 桦甸市| 通山县| 上栗县| 清流县| 友谊县| 巴林左旗| 栾川县| 湖南省| 茶陵县| 齐齐哈尔市| 随州市| 曲松县| 阿拉尔市| 独山县| 南乐县| 肥乡县| 南投市|