Populating fields based on the value of another field

Another popular use for client-side scripting is populating a field based on the value of another. A common use of this is when selecting a user in a field and then wanting, for example, to automatically populate the company, telephone number, and job title.

For this example, you will want to use an onChange client script. By setting the onChange field to be the user field, you can then get the rest of the user data using a client script. The best practice for this is to use a GlideAjax call, which we will explore in advanced client scripting later in the next chapter.

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.