Reference field attributes for input form screens in offline mode

  • Release version: Australia
  • Updated June 8, 2026
  • 2 minutes to read
  • Summarize
    Summarized using AI
    This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.

    Summary of Reference field attributes for input form screens in offline mode

    This topic explains how ServiceNow customers can configure reference fields in input form screens to function effectively in offline mode. It focuses on setting attributes that define which data to display and how users can search and select reference data when disconnected from the network. Proper configuration ensures a seamless offline experience by controlling cached data and search behavior on mobile devices.

    Show full answer Show less

    Key Features

    • Required Attributes:
      • SourceTable: Specifies the table from which to derive the reference qualifier.
      • SourceFieldName: The field name in the source table that is referenced.
      • TargetTable: The table targeted by the reference qualifier.
    • Optional Attributes:
      • OfflineMobileViewId: Defines the mobile card view used to display reference data offline, overriding the MobileViewId.
      • EnableSearch: Controls whether a search bar appears; set to true or false.
      • OfflineConditions: An encoded query to filter reference data offline, taking precedence over Conditions and supporting offline-compatible filters.
      • SearchType: Specifies search logic, either startswith or contains, defaulting to startswith.
      • OfflineFetchScript: A script to specify up to 1,000 Sys IDs of reference records to cache offline, enabling precise control over cached data.
      • OfflineMaxNumRecords: Sets the maximum number of records to cache offline per reference input, with 1,000 as the maximum.

    Practical Implementation

    To optimize offline reference data, customers can create a Script Include that dynamically fetches relevant Sys IDs to cache. For example, a script can retrieve active users sharing the logged-in user’s location plus the user, ensuring offline access to pertinent "Assigned To" records without caching unnecessary data.

    Using this approach, the OfflineFetchScript attribute is set on the input field, invoking the script to return a curated list of records for offline caching. This method respects the 1,000 record cache limit while improving user experience in offline scenarios.

    Why It Matters

    Configuring these attributes allows ServiceNow customers to tailor offline reference field behavior, improving performance and usability on mobile devices. By controlling cached records and search parameters, users can efficiently find and select records offline, maintaining productivity without network connectivity.

    Configure the fields that you want to use and the data you want to display in offline mode by using various input attributes.

    Note:
    You must create an input form screen before you create variables and attributes. For information about creating an input form screen, see Configure an input form screen.

    Reference inputs

    Use reference inputs for inputs that reference a field on a table. These inputs work like reference fields in the forms on your instance. You can configure your reference input with conditions, reference qualifiers, and a search option to help your users find what they need quickly.

    You can use these attributes with reference inputs.

    Note:
    All attributes are case-sensitive.
    Table 1. Required attributes
    Attribute Description
    SourceTable The source table for your reference qualifier.
    SourceFieldName The field name of the referenced field in the source table.
    TargetTable The table you want to target for your reference qualifier.

    The following additional attributes are optional:

    Table 2. Additional attributes
    Attribute Description
    OfflineMobileViewId Define the mobile card used to display reference field data in offline mode. The OfflineMobileViewId attribute takes precedence over the MobileViewId attribute.
    EnableSearch Option to determine whether the search bar displays. The value must be true or false.
    OfflineConditions Encoded query condition used to query the reference data. The OfflineConditions attribute takes precedence over the Conditions attribute.
    Note:
    This attribute can also be used when the Conditions attribute has a condition that can't be supported in offline.
    SearchType Defines the query used for search. The value can be starts_with or contains. If this attribute is not configured, the instance uses starts_with by default on the display label column.
    OfflineFetchScript

    Use to specify a list of Sys IDs for reference records. Using this attribute, you can define what records to cache while in offline mode.

    Reference fields can return many thousands of records, but only 1,000 records are supported to cache for offline mode. Use this attribute to define the specific records (1,000 or less) that you want to cache for use while offline.

    If this attribute is not used, then the first 1,000 records returned are cached. An example script is shown in the next section.

    OfflineMaxNumRecords Defines the number of records that you can cache in offline mode. The maximum number is 1000.

    You can set a different value for each reference input.

    OfflineFetchScript implementation example

    This example shows how the system dynamically retrieves users who share the logged-in user's location for the Assigned Tofield in the input form.
    1. Create a Script Include to return active users in the same location as the logged-in user, plus the user themself.
      var MobileOfflineUserFetch = Class.create(); 
      MobileOfflineUserFetch.prototype = { 
          initialize: function() {}, 
       
          getUsersByMyLocation: function() { 
              var ids = []; 
              var myId = gs.getUserID(); 
              var myLoc = gs.getUser().getLocation(); 
       
              ids.push(myId); // include myself 
       
              if (!myLoc) 
                  return ids.join(','); 
       
              var gr = new GlideRecord('sys_user'); 
              gr.addActiveQuery(); 
              gr.addQuery('location', myLoc); 
              gr.setLimit(1000); // Reference field limitation 
              gr.query(); 
       
              while (gr.next()) { 
                  ids.push(gr.getUniqueValue()); 
              } 
              return ids.join(','); 
          }, 
       
          type: 'MobileOfflineUserFetch' 
      }; 
    2. Add the OfflineFetchScript input attribute to the Assigned To input field and set the value to the following:
      javascript: new MobileOfflineUserFetch().getUsersByMyLocation()