ServiceNow reference fields

A ServiceNow reference field contains a sys_id for another record in the ServiceNow system. Reference field values can be displayed in Mobile Reach Apps using the associated display value field (dv field) for that reference field or by using the Cache component defined with the sys_id and field name.

Fields with references that are two deep (a field in the main table references a field in another table that references a field in a third table) cannot be used in Apps. Instead, joined forms referred to as views must be used to put all of the fields in one view.

NOTE: DV fields can be used in search results, but not in SQL search queries or with Search components as the value to compare against. Instead, use views.

dv_fields can be turned off (not displayed) at the server or table level by setting nodvfields=1 in the ServiceNow.xml file. If dv_fields are turned off at the server level, they can be turned on at the table level by setting dvfields=1 for that table.

If your App is task-oriented and uses an import set (staging form), you can configure reference fields in the import set. When searching or copying data into the reference field, copy the regular value (sys_id) into the regular field and copy the dv_value into the dv_value field. Copying the dv_value is not necessary, since this field is read-only. If a change is somehow made to this field on the client device, the change will be ignored by the server. Adding the dv_value to the application allows the user to see the more readable value and comes under the heading of best practices.

For example, if a Location field is included in the import set, set it up as a reference field, referencing cmn_location. In the App, when the Location field value is searched for and found in cmn_location, copy the sys_id value into the u_location field and the name value into the dv_u_location field. Use dv_u_location to display the value to the user. Since this is a display only field, dv_u_location will not be set in the import set when the record is inserted, but the ServiceNow handling of the reference field will set the value of the Location field.

ServiceNow fields can also incorporate static mapped values that are not reference fields. For example, the Impact field in the database maps High, Medium, Low, to 1, 2, 3, respectively. If these values aren’t going to change, then a separate table isn’t needed for the values.

Tutorial