Code

GlideRecord property assignment


Maintenance
1h 15m to fix

Why is this an issue?

Property assignment in GlideRecord may, in specific scenarios, cause unwanted and/or difficult to diagnose results such as:

  • Duplicate information
  • Clear columns in the database
  • Unable to use variable as field parameter

Example:

1// setting new Short Description 2current.short_description = "This is a Test";

In this example, short_description is not only a field, but an Object with several attributes:

short_description type field

Best practices

Use setValue() method as follow:

1// setting new Short Description 2current.setValue("short_description", "This is a Test"); 3 4// using variable 5var fields_value = ["short_descrption", "This is a Test"]; 6current.setValue(fields_value[0], fields_value[1]); 7 8// for a reference field 9current.setValue("assigned_to", "46f09e75a9fe198100f4ffd8d366d17b");

There is also setDisplayValue():

1// setting record by Display Value 2current.setDisplayValue("assigned_to", "Beth Anglin");
Never dot-walk to sys_id
No Eval

© Copyright 2025. All rights reserved.