--- title: Field script use cases description: Common use cases for field customization scripts. locale: en-US canonical_url: https://www.servicenow.com/docs/r/australia/api-reference/scripts/r\_UsefulFieldScripts.html release: australia product: Scripts classification: scripts topic_type: reference last_updated: "2026-03-12" reading_time_minutes: 6 breadcrumb: [Useful scripts, Scripting, API implementation, API implementation and reference] --- # Field script use cases Common use cases for field customization scripts. **Warning:** The customization described here was developed for use in specific instances, and is not supported by Now Support. This method is provided as-is and should be tested thoroughly before implementation. Post all questions and comments regarding this customization to our community [forum](http://community.service-now.com/). For more information, see [Server API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/api-server.md). ## Automatically populate a field The following example shows how to use a client script to auto-fill a **Short Description** based on the selected **Subcategory**. In this case, if the table has a record with **Subcategory** = Password and **Short Description** = Password Reset. When the user selects the **Subcategory** of **Password** on the Incident form, a client script looks up the matching record and sets **Short Description** equal to Password Reset. Client script settings: - **Type** = onChange - **Table name** = incident - **Field name** = Subcategory ``` function onChange(control, oldValue, newValue, isLoading){ if(isLoading){return;} var newrec = gel('sys_row'); //Check if new record if (newrec.value == -1) { var lookup = new GlideRecord('u_short_desc_lookup'); lookup.addQuery('u_subcategory', g_form.getValue('subcategory')); lookup.query(); var temp; //temp var - reusable if(lookup.next()){ temp = lookup.u_short_description; if(null != temp) { //Set the form value from lookup if there is a lookup value g_form.setValue('short_description', temp); } else { g_form.setValue('short_description',""); } } else { //If a lookup record does not exist based on lookup.addQuery   //Then set to UNDEFINED or NULL depending on type g_form.setValue('short_description',"");   } } } ``` ## Disable HTML tags in descriptions This code disables HTML tags in **Description** and **Short Description** fields by substituting the tags with non-executing versions. ``` doit(); function doit(){ var desc = current.description.toString(); var shdesc = current.short_description.toString(); if(desc.indexOf('script>')>-1|| shdesc.indexOf('script>')>-1){ desc = desc.replace(/