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 ...

Get Mastering ServiceNow Scripting now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.