{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":39199,"path":"platform-administration/r_CreateCustomDataLookups.md","title":"Create custom data lookups","bundle":null,"doc_type":null,"release":"australia","body":"\n# Create custom data lookups\n\nCreating custom data lookups involves adding a lookup value, creating the definition, and activating data lookup.\n\n## Create a custom data lookup table\n\nCreate a custom table to store lookup data.\n\nThe custom table must extend the Data Lookup Matcher Rules `[dl_matcher]` table. For example, this custom lookup table stores information about VIP callers and incident assignments.\n\n|Field|Sample value|\n|-----|------------|\n|Label|VIP Caller Lookup|\n|Table name|u\\_vip\\_caller\\_lookup|\n|Extends base table|dl\\_matcher|\n|Create new module|True|\n|Add module to menu|System Policy|\n\n## Add a data lookup value to the data lookup table\n\nThe columns of a data lookup table contain both matcher and setter field data.\n\n### Before you begin\n\nRole required: admin\n\n### About this task\n\nEach data lookup is a query that searches for a row containing values that match the matcher fields. The data lookup then returns the value listed in the setter fields. For example, this Priority Data Lookup \\[dl\\_u\\_priority\\] table lists the combinations of impact and urgency \\(matcher fields\\) that produce a particular priority value \\(setter field\\).\n\n|Matcher fields|Setter field|\n|--------------|------------|\n|Impact|Urgency|Priority|\n|1 - High|1 - High|1 - Critical|\n|1 - High|2 - Medium|2 - High|\n|1 - High|3 - Low|3 - Moderate|\n|2 - Medium|1 - High|2 - High|\n|2 - Medium|2 - Medium|3 - Moderate|\n|2 - Medium|3 - Low|4 - Low|\n|3 - Low|1 - High|3 - Moderate|\n|3 - Low|2 - Medium|4 - Low|\n|3 - Low|3 - Low|5 - Planning|\n\n### Procedure\n\n1.  In the navigation filter, enter the name of the new custom lookup table.\n\n    For example, `u_vip_caller_lookup.list`.\n\n2.  Configure the list and create new fields.\n\n    For this example, create the new fields in the following table.\n\n    |Name|Type|Field length or Table to reference|\n    |----|----|----------------------------------|\n    |Caller|Reference|User \\[sys\\_user\\]|\n    |Priority|Integer| |\n    |Assignment Group|Reference|Group \\[sys\\_user\\_group\\]|\n\n    For more information, see [Configuring lists on the ServiceNow AI Platform](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-administration/list-administration/c_ListConfiguration.md).\n\n3.  From the table list, select **New** and enter appropriate matcher and setter field values.\n\n    For example:\n\n    |Matcher field|Setter fields|\n    |-------------|-------------|\n    |Caller|Priority|Assignment Group|\n    |Beth Anglin|2|VIP Issues|\n    |Fred Luddy|1|VIP Issues|\n\n    **Note:** Each row in a data lookup table must be unique.\n\n\n## Create a data lookup definition record\n\nData lookup requires a definition record that specifies how to set one or more field values when specified conditions are met.\n\n### Before you begin\n\nRole required: admin\n\n### Procedure\n\n1.  Navigate to **All** &gt; **System Policy** &gt; **Rules** &gt; **Data Lookup Definitions**.\n\n2.  Select **New**.\n\n3.  Select **Data Lookup Rule**.\n\n4.  Complete the Data Lookup Rule form using the following table.\n\n<table id=\"table_qcb_2jk_t1b\"><thead><tr><th>\n\nField\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nName\n\n</td><td>\n\nEnter a unique name to identify the definition record.\n\n</td></tr><tr><td>\n\nSource Table\n\n</td><td>\n\nSelect the table containing the fields you want to automatically update with lookup values. Data Lookup Definitions are not inherited by extension tables. For example, a Data Lookup Definition on the Task table cannot match values on the Incident table.\n\n</td></tr><tr><td>\n\nMatcher Table\n\n</td><td>\n\nSelect the table containing the lookup values. This table should always start with a u\\_ prefix. This table can be any table within the current scope containing the lookup values.**Note:** The list shows only tables and database views that are in the same scope as the catalog data lookup definition.\n\n</td></tr><tr><td>\n\nActive\n\n</td><td>\n\nSelect this check box to run this data lookup rule. Clear the check box to ignore this data lookup rule.\n\n</td></tr><tr><td>\n\nRun on form change\n\n</td><td>\n\nSelect this check box to automatically look up values whenever a user or onChange client script changes a field value on a source table form.\n\n **Note:** This does not include changes automatically made by other data lookup rules, such as the Priority Lookup Rules.\n\n</td></tr><tr><td>\n\nRun on insert\n\n</td><td>\n\nSelect this check box to automatically look up values whenever a user creates a new record.\n\n</td></tr><tr><td>\n\nRun on update\n\n</td><td>\n\nSelect this check box to automatically look up values whenever a user saves or updates a record.\n\n</td></tr></tbody>\n</table>5.  Select and hold \\(or right-click\\) the form header and select **Save**.\n\n6.  From the **Matcher Field Definitions** related list, click **New**.\n\n7.  Complete the Matcher Field Definitions using the following table.\n\n    A data lookup only occurs on fields with matcher field definitions. The data lookup uses the values of the source table fields to look up one or more values from the matcher table. Note that data lookup does not work with **Journal** type fields.\n\n<table id=\"table_avq_1qq_wq\"><thead><tr><th>\n\nField\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nData Lookup\n\n</td><td>\n\nDisplays the name of the parent data lookup definition record.\n\n</td></tr><tr><td>\n\nSource table field\n\n</td><td>\n\nSelect the field from the source table that contains the data to match.\n\n</td></tr><tr><td>\n\nMatcher table field\n\n</td><td>\n\nSelect the field from the matcher table that contains the data to match. This table can be any table within the current scope containing the lookup values.\n\n</td></tr><tr><td>\n\nExact lookup match\n\n</td><td>\n\nSelect this check box to require the matcher table to contain a matching row for every possible combination of values \\(including empty values\\). Clearing this check box means that any empty values in the matcher table match any value. For example, suppose the Priority field is empty in the matcher table. When this check box is selected, there is a match only when the Priority value is empty in the source table row. When this check box is cleared, the empty matcher field value matches any value in the source table field.\n\n **Note:** If the lookup does not require an exact match, matcher table rows containing empty values are treated as wild cards, matching all values.\n\n</td></tr></tbody>\n</table>8.  Select **Submit**.\n\n9.  From the **Setter Field Definitions** related list, click **New**.\n\n10. Complete the Setter Field Definitions form using the following table.\n\n    |Field|Description|\n    |-----|-----------|\n    |Data Lookup|Displays the name of the parent data lookup definitions record.|\n    |Source table field|Select the field from the source table that the data lookup updates.|\n    |Matcher table field|Select the field from the matcher table that provides the new value for the update.|\n    |Always replace|Select this check box to replace any existing value with a value from the data lookup. Clear this check box to ignore the update if the field has an existing value.|\n\n11. Select **Submit**.\n\n12. Select **Update**.\n\n\n## Create a data lookup module\n\nYou can create a module for data lookup so it appears in the instance application navigator.\n\n### Before you begin\n\nRole required: admin\n\n### Procedure\n\n1.  Navigate to **All** &gt; **System Definition** &gt; **Application Menus**, then select an application to add the module to.\n\n2.  In the Modules related list, select **New**.\n\n3.  Configure a module for the data lookup table you created using the following properties.\n\n    |Property|Required value|\n    |--------|--------------|\n    |Table|Select the data lookup table you created in Step 2. For example u\\_vip\\_caller\\_lookup.|\n    |Link type|List of Records|\n\n4.  Select **Submit**.\n\n\n## Troubleshooting data lookup\n\nIf the custom data lookup definition rules are not behaving as expected, check for certain conditions.\n\n-   Verify that the data lookup definition is set to run on the appropriate events.\n-   Verify that the matcher field is not read-only. Because users cannot change read-only fields, user interactions cannot trigger an on form change event for read-only fields.\n-   Verify a client script is not changing a field value. Client scripts can trigger **Run on form change** events even on read-only fields.\n-   Verify that the data in the matcher table is correct.\n-   If the lookup requires an exact match, verify that there is a matcher table row for each possible combination \\(including blank values\\). The lookup fails if cannot find a matching value.\n-   Verify that you have not created a recursive rule, such as:\n\n    If Field A = 1, then Field B =2. If Field B = 2, then Field A = 2.\n\n\n"}}