GlideForm - setValue(String fieldName, String value, String displayValue)

Sets the value and display value of the specified field.

When defining a value in a choice list, be sure to use number value rather than the label.

To improve performance by preventing a round trip, use this method not setValue(fieldName, value).

Note: The method setValue() can cause a stack overflow when used in an OnChange client script. This is because every time the value is set, it will register as a change, which may re-trigger the OnChange client script. To prevent this, perform a check that will validate that the new value will be different from the old value. For example, before performing setValue(shortDesc, newValue.toUpperCase());, validate that the short description is not already uppercase. This will prevent the client script from applying the toUpperCase() more than once.
Table 1. Parameters
Name Type Description
fieldName String Name of the field.
value String Value in the database.
displayValue String Value to be displayed.
Table 2. Returns
Type Description
void

g_form.setValue('short_description', 'replace this with appropriate text', 'Change this text');