{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":35055,"path":"mobile/reference-fields-offline-attributes.md","title":"Reference field attributes for input form screens in offline mode","bundle":null,"doc_type":null,"release":"australia","body":"\n# Reference field attributes for input form screens in offline mode\n\nConfigure the fields that you want to use and the data you want to display in offline mode by using various input attributes.\n\n**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](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/mobile/parameter-screen-config.md).\n\n## Reference inputs\n\nUse reference inputs for inputs that reference a field on a table. These inputs work like [reference fields](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/c_ReferenceField.md) 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.\n\nYou can use these attributes with reference inputs.\n\n**Note:** All attributes are case-sensitive.\n\n|Attribute|Description|\n|---------|-----------|\n|SourceTable|The source table for your reference qualifier.|\n|SourceFieldName|The field name of the referenced field in the source table.|\n|TargetTable|The table you want to target for your reference qualifier.|\n\nThe following additional attributes are optional:\n\n<table id=\"table_anh_jbw_b4b\"><thead><tr><th>\n\nAttribute\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nOfflineMobileViewId\n\n</td><td>\n\nDefine the mobile card used to display reference field data in offline mode. The **OfflineMobileViewId** attribute takes precedence over the **MobileViewId** attribute.\n\n</td></tr><tr><td>\n\nEnableSearch\n\n</td><td>\n\nOption to determine whether the search bar displays. The value must be **true** or **false**.\n\n</td></tr><tr><td>\n\nOfflineConditions\n\n</td><td>\n\nEncoded 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.\n\n</td></tr><tr><td>\n\nSearchType\n\n</td><td>\n\nDefines 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.\n\n</td></tr><tr><td>\n\nOfflineFetchScript\n\n</td><td>\n\nUse to specify a list of Sys IDs for reference records. Using this attribute, you can define what records to cache while in offline mode.\n\n 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.\n\n If this attribute is not used, then the first 1,000 records returned are cached. An example script is shown in the next section.\n\n</td></tr><tr><td>\n\nOfflineMaxNumRecords\n\n</td><td>\n\nDefines 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.\n\n</td></tr></tbody>\n</table>## OfflineFetchScript implementation example\n\nThis example shows how the system dynamically retrieves users who share the logged-in user's location for the **Assigned To**field in the input form.\n\n1.  Create a Script Include to return active users in the same location as the logged-in user, plus the user themself.\n\n    ```\n    var MobileOfflineUserFetch = Class.create(); \n    MobileOfflineUserFetch.prototype = { \n        initialize: function() {}, \n     \n        getUsersByMyLocation: function() { \n            var ids = []; \n            var myId = gs.getUserID(); \n            var myLoc = gs.getUser().getLocation(); \n     \n            ids.push(myId); // include myself \n     \n            if (!myLoc) \n                return ids.join(','); \n     \n            var gr = new GlideRecord('sys_user'); \n            gr.addActiveQuery(); \n            gr.addQuery('location', myLoc); \n            gr.setLimit(1000); // Reference field limitation \n            gr.query(); \n     \n            while (gr.next()) { \n                ids.push(gr.getUniqueValue()); \n            } \n            return ids.join(','); \n        }, \n     \n        type: 'MobileOfflineUserFetch' \n    }; \n    ```\n\n2.  Add the OfflineFetchScript input attribute to the **Assigned To** input field and set the value to the following:\n\n    ```\n    javascript: new MobileOfflineUserFetch().getUsersByMyLocation()\n    ```\n\n\n**Parent Topic:**[Input forms in offline](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/mobile/offline-input-form.md)\n\n"}}