Scoped GlideRecord - setValue(String name, Object value)

Sets the value of the field with the specified name to the specified value.

Normally the script does a gr.category = value. However, if the element name is itself a variable then gr.setValue(elementName, value) can be used. When setting a value, ensure the data type of the field matches the data type of the value you enter.

Table 1. Parameters
Name Type Description
name String Name of the field.
value Object The value to assign to the field.
Table 2. Returns
Type Description
var elementName = 'short_description'; 
var gr = new GlideRecord('incident'); 
gr.setValue(elementName, "My DB is not working");