Dot-walking examples
Summarize
Summary of Dot-walking examples
Dot-walking in ServiceNow enables you to access and reference fields on related tables directly from forms, lists, scripts, and variables. This powerful feature simplifies querying and displaying data across related records by traversing reference fields using dot notation.
Show less
Key Features
- List Fields: You can filter and display related table fields in lists by selecting "Show Related Fields." For example, filtering Incidents by the caller’s company is done by dot-walking from Incident → Caller → Company. The interface visually indicates how many levels deep you have navigated with dots.
- Condition Builders: Dot-walking allows you to create detailed queries involving related tables. By enabling "Show Related Fields," you can build conditions such as filtering Incidents assigned to a user by last name (e.g., Assigned to → Last name → "Anglin").
- List Collectors: When configuring forms, list collectors let you select fields from related tables by expanding reference fields marked with a plus icon. The selected fields show their full dot-walked path, such as Assigned to.Active.
- Scripts: You can use dot-walking in both server-side and client-side scripts. Server-side scripts require prefixing with
current., e.g.,current.openedby.manager. Client-side scripts access related fields via form references, enabling dynamic behaviors like highlighting VIP callers based on related field values. - Variables: Dot-walking is supported in variables used in templates and notifications. You can reference nested fields, such as
${assignedto.manager.mobilephone}, to dynamically pull related data. - Tree Pickers: Tree pickers provide a hierarchical interface to select reference records from parent-child relationships, such as configuration items or user groups. They can be configured to handle large hierarchies by setting the
glide.ui.groupheirarchy.maxnodesproperty and enablingtreepicker=truein dictionary attributes.
Practical Benefits for ServiceNow Customers
- Enables more sophisticated filtering and querying by leveraging related records without complex scripting or data duplication.
- Enhances form and list configurations by exposing relevant related data for efficient use and display.
- Supports dynamic UI behavior through client scripts that respond to related record data.
- Improves notification and template flexibility by pulling detailed related information via dot-walked variables.
- Simplifies navigation and selection of hierarchical data using tree pickers, which can be scaled for large datasets.
Access fields on a related table from a form, list, or script by dot-walking. This topic includes examples of the different ways that you can dot-walk.
List fields
You can dot-walk to related fields in a list, such as the field list in a filter. This example demonstrates how to filter the Incident [incident] table by the company of the caller who registered the incident.
When you open the list of fields that you want to filter, you see the list of available Incident table fields. The reference fields are followed by the related fields. For example, Caller is followed by , which means that Caller is a reference field, and the related fields are user fields on the Caller record.
If the related fields are not present in the list, select Show Related Fields at the bottom of the list. When you select Show Related Fields, the menu reloads to display related fields.
When you select a related field, the menu reloads with the fields of the related table. For example, when you select Company under Caller → User fields, the field then becomes Caller.CompanyEach selected reference is stored at the top of the fields menu, and the number of dots preceding the field label indicate how many dots from the initial record the user has reached.
The following example image shows that the user is at Incident.Caller.Company. You can return to higher levels in the hierarchy by selecting fields located at the top of the menu. For instance, selecting Incident fields returns to the list of incident fields.
The related fields can be removed by selecting Remove Related Fields at the bottom of the list.
Condition builders
You can make a detailed query on a table by dot-walking in the condition builder.
To dot-walk in a condition builder, first select Show Related Fields on the fields menu. This action allows you to add fields from related tables to your query.
For example, you could dot-walk fields in a condition builder to find all Incident records assigned to one specific user, Beth Anglin.To do so, navigate to , and then open the condition builder. In the fields menu, selects Show Related Fields and then open the fields menu again to select Assigned to → User fields. Opens the fields menu again to select Last name. Then, build the following condition: [Last name] [is] [Anglin]. Finally, select Run. The Incident list displays only the records assigned to Beth Anglin.
List collectors
When selecting a list of fields from a list collector (for example, when you're configuring a form), you can dot-walk to fields from other forms.
Once a reference field is highlighted, the expand icon () appears above the add icon.
Once the field is added to the Selected pane, it appears with its full dot-walked syntax. (For example, Assigned to.Active).
Scripts
You can dot-walk within a script by invoking the dot-walk syntax. This functionality requires a knowledge of JavaScript.
For scripts that run on the server side, such as business rules, it is necessary to add current.
try{
current.opened_by.manager;
}
catch(err){}function onChange(control, oldValue, newValue, isLoading){
//wait until there is a valid record in the field
if(newValue){
//get the caller object so we can access fields
var caller = g_form. getReference('caller_id');
var callerLabel = document.getElementById('label.incident.caller_id');
var callerField = document.getElementById('sys_display.incident.caller_id');
//check for VIP status
if(caller.vip == 'true') {
//change the caller label to red background
//style object is CSSStyleDeclaration, style names are not standard css names
if(callerLabel)
document.getElementById('label.incident.caller_id').style.backgroundColor = 'red';
//change the caller's name field to red text
if(callerField)
document.getElementById('sys_display.incident.caller_id').style.color = 'red';
}
else { //not a VIP, remove temporary styles if(callerLabel)
document.getElementById('label.incident.caller_id').style.backgroundColor = '';
if(callerField)
document.getElementById('sys_display.incident.caller_id').style.color = '';
}
}
}Variables
Often, you can add variables into templates, notifications, or other forms where a value is being called from the form.
For example, ${assigned_to} is the variable for the Assigned to field.
As shown in the example, you can dot-walk to fields on the original record of any reference field. It is possible to dot-walk to any field on the assigned_to record, for example, ${assigned_to.manager}.
When you dot-walk, you can have a longer chain if you need it, as in this example: ${assigned_to.department.manager.mobile_phone}.
Sometimes, you can select this variable from a tree picker.
Tree pickers
- Configuration Items (CIs) that are subordinate to another, higher-level CI.
- Members of a certain group. For example, you would use a tree picker to look up a user in the Service Desk group.
- Reference elements for any hierarchical table. A hierarchical table is any table that has a parent field pointing back at itself. The Group [sys_user_group] table, for example, would be considered a hierarchical table because certain groups are children of parent groups.