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 2
// setting new Short Description current.short_description = "This is a Test";
In this example, short_description is not only a field, but an Object with several attributes:
Best practices
Use setValue() method as follow:
1 2 3 4 5 6 7 8 9
// setting new Short Description current.setValue("short_description", "This is a Test"); // using variable var fields_value = ["short_descrption", "This is a Test"]; current.setValue(fields_value[0], fields_value[1]); // for a reference field current.setValue("assigned_to", "46f09e75a9fe198100f4ffd8d366d17b");
There is also setDisplayValue():
1 2
// setting record by Display Value current.setDisplayValue("assigned_to", "Beth Anglin");