Field script use cases
-
- UpdatedJan 30, 2025
- 4 minutes to read
- Yokohama
- Building applications
Common use cases for field customization scripts.
For more information, see Server API reference.
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.
- Type = onChange
- Table name = incident
- Field name = Subcategory
Disable HTML tags in descriptions
Eliminate leading and trailing spaces in fields
Make a field label flash
- tablename.fieldname
- RGB color or acceptable CSS color like "blue" or "tomato"
- Integer that determines how long the label flashes:
- 2 for a 1-second flash
- 0 for a 2-second flash
- -2 for a 3-second flash
- -4 for a 4-second flash
Make a field label bold
Make fields read-only
- Incident state
- Impact
- Urgency
- Priority
- Configuration item
- Assigned to
Set current date/time in field
You can set date and time values in client scripts and script includes.
- Client script
- You can use the following two lines to set the current date and time in a date/time field. This approach bypasses the problem of getting the value into the proper format and proper time zone.
- System script include
Toggle the timer field by field name
Modify GlideDateTime field value
The following example uses a server-side script to access a GlideDateTime field.