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

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.

主站蜘蛛池模板: 嘉禾县| 三明市| 黄陵县| 潮州市| 沙湾县| 方正县| 怀宁县| 抚州市| 南汇区| 临朐县| 长岛县| 烟台市| 奉贤区| 卢龙县| 双鸭山市| 响水县| 墨脱县| 嘉鱼县| 鄢陵县| 全椒县| 六盘水市| 长葛市| 台中市| 竹北市| 芦溪县| 交城县| 英超| 临武县| 安多县| 杭锦后旗| 儋州市| 海淀区| 平阳县| 开化县| 电白县| 鄯善县| 江北区| 邯郸县| 乌拉特中旗| 汨罗市| 田阳县|