As we learned in a previous chapter, dot-walking allows you to access fields on related records via a reference field (a type of field which contains a reference to another record), by chaining field names separated by dots. For example, to get the email address of the person to whom an incident is assigned from a business rule on the Incident table, you might use the following code:
var assigneeEmail = current.assigned_to.email.toString();
You might notice that we also used the toString()
method in the preceding snippet. This is because, as we saw in the server-side Glide API documentation, fields accessed from server-side GlideRecords
return GlideElement
objects; not just values. JavaScript will generally coerce (sometimes referred to as casting) values to whatever datatype you're trying to use it as, but it is always best to explicitly convert values derived from GlideElement
objects. Otherwise, you risk getting the wrong data type. Since GlideElement objects...