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

onLoad

The onLoad client script type runs script when a form is loaded. This can be helpful to manipulate data on a form before a user starts using it. Sometimes, when a form loads slowly, it is possible to see onLoad client scripts doing their job.

When selecting the onLoad type, the script field will be populated with the onLoad function ServiceNow provides for you, as long as the script field hasn't already been edited. The script looks as follows:

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

}

This is the onLoad function to put your script into. Any script running onLoad will take time to run and slow down loading time, so it is always worth trying to keep onLoad client scripts to a minimum, and short, if necessary. I have been involved in projects simply to reduce the amount of onLoad client scripts on forms to reduce load times.

Try to have only one onLoad client script for each table, rather than multiple. This makes it easy to maintain, as all onLoad code is in one place, and you can be completely confident of the order the onLoad code will run in.

In the following figure, Figure 3.1, we can see what this type of client script will look like:

Figure 3.1: Sample onLoad client script

In the preceding figure, we can see an onLoad client script ready to be written for the incident table. As the comment states in the code, replace the comment in the code with the functionality of your script, and then begin writing underneath the comment inside the onLoad function.

主站蜘蛛池模板: 徐州市| 广德县| 贺州市| 泌阳县| 临颍县| 文安县| 墨竹工卡县| 仁怀市| 五常市| 临沧市| 阿巴嘎旗| 鲁甸县| 杭州市| 禄劝| 金塔县| 洪湖市| 秦皇岛市| 保康县| 睢宁县| 密山市| 灌南县| 财经| 鄂伦春自治旗| 桑日县| 永州市| 宽甸| 台中市| 弥勒县| 隆安县| 广汉市| 台北县| 大同县| 凤冈县| 冕宁县| 临泉县| 白山市| 巴林右旗| 天津市| 合川市| 义马市| 山东|