Dot-walking examples
Summarize
Summary of Dot-walking examples
Dot-walking in ServiceNow allows you to access fields on related tables from forms, lists, scripts, conditions, and variables by traversing reference relationships. This enables more detailed queries, dynamic scripting, and enhanced data retrieval across related records, improving your ability to filter, display, and manipulate data efficiently within the platform.
Show less
Using Dot-walking in Different Contexts
- List Fields: You can dot-walk in list filters by expanding reference fields to related fields. For example, filtering the Incident table by the caller’s company involves selecting
Caller.Company. Related fields can be shown or hidden via options at the bottom of the fields list. - Condition Builders: Dot-walking allows creating detailed queries by selecting related table fields. For instance, filtering incidents assigned to a user by dot-walking to
Assigned to → Last nameand setting the condition accordingly. - List Collectors: When configuring forms, you can dot-walk to select fields from related records within list collectors. Reference fields show a green plus and an expand icon to reveal related fields, which appear in their full dot-walked syntax once selected. Note that adding new fields via dot-walking in the Create new field section is unsupported and can cause issues.
- Scripts: Dot-walking syntax is used in server-side scripts (business rules) with the
currentobject (e.g.,current.openedby.manager) and in client-side scripts withoutcurrent. This enables accessing related record fields dynamically, such as highlighting a VIP caller by checking a related field’s value. - Variables: Variables in templates or notifications support dot-walking to reference fields on related records, allowing long chains such as
${assignedto.department.manager.mobilephone}to pull detailed information. - Tree Pickers: Tree pickers provide a hierarchical, expandable view for selecting reference records within parent-child relationships, such as groups and users. This is especially useful for assigning records within nested groups. Configuration options control the number of nodes displayed and require setting the
treepicker=trueattribute on the dictionary field.
Practical Benefits for ServiceNow Customers
- Enable precise filtering and querying across related records without creating additional fields.
- Enhance scripts and client-side logic by dynamically accessing related data.
- Improve form configuration and user experience with intuitive field selection and hierarchical lookups.
- Use variables to customize notifications and templates with detailed, related record information.
- Maintain platform stability by following supported dot-walking practices, especially in list collectors.
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 select Company under Caller → User fields, the field then becomes Caller.Company.
The example 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.
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.
The following GIF shows how you would dot-walk fields in a condition builder to find all Incident records assigned to one specific user, Beth Anglin. In the example, the user navigates to and then opens the condition builder. In the fields menu, the user first selects Show Related Fields and then opens the fields menu again to select Assigned to → User fields. The user opens the fields menu again to select Last name. The user builds the following condition: [Last name] [is] [Anglin]. After the user selects Run, the Incident list displays only the records assigned to Beth Anglin.
List collectors
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.
The following example shows how you would use a tree picker to assign an Incident record to a user in the Database group.
You would first navigate to any Incident record and then enter Database in the Assignment group field.
In this example, the Database group is a parent group with multiple child groups under it. When you select the search icon ( ) next to the Assigned to field, a window displays reference fields in the Database group.
Reference fields have the expand icon (+) next to their name. Clicking the + expands a list of the fields on that referenced field. In this example, expanding the Database Atlanta or Database San Diego fields opens a list of user records within each child group.
You would select any one of the user records to add it as a value in the Assigned to field.