GlideRecord - setValue(String name, Object value)

Sets the specified field to the specified value.

Normally a script would do a direct assignment, for example, gr.category = value. However, if in a script the element name is 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. This method cannot be used on journal fields.

If the value parameter is null, the record is not updated, and an error is not thrown.

Table 1. Parameters
Name Type Description
name String Field name
value Object A value to be assigned.
Table 2. Returns
Type Description
void

Scoped equivalent

To use the setValue() method in a scoped application, use the corresponding scoped method: Scoped GlideRecord - setValue(String name, Object value).