{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":42675,"path":"platform-user-interface/t_CreateDefinedRelatedLists.md","title":"Create defined related lists","bundle":null,"doc_type":null,"release":"australia","body":"\n# Create defined related lists\n\nYou can add default related lists to the form for all users to see when viewing records.\n\n## Before you begin\n\nRole required: related\\_list\\_admin\n\n## About this task\n\nFor example, you may include a list of related incidents at the bottom of a problem record, or a list of members at the bottom of a group record. This functionality depends on reference fields or many-to-many table relationships. If two tables are related via the system dictionary, one can appear as a related list on the other.\n\nDefined related lists allow relationships between arbitrary tables to be expressed as a related list. Any two tables that can have a logical relationship can appear as a parent/child pair via a related list. The following are some examples.\n\n-   On an incident record, show all incidents opened by the same caller.\n-   On a user record, show the last 20 transactions that user has made.\n-   On an incident record, show all problems opened on the reported CI.\n\nThese relationships are beyond the relationships normally defined in the system dictionary through reference fields and many-to-many relationships.\n\nEvery related list requires a relationship record. Before creating a relationship, verify that there is not an existing relationship record that already provides the needed information. Use the following steps to create a relationship record.\n\n## Procedure\n\n1.  Click **System Definition** &gt; **Relationships**.\n\n2.  Click **New**.\n\n3.  Specify the relationship record fields.\n\n<table id=\"table_rqf_w5c_xp\"><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\nType the name of the related list. The form configuration page displays this name in the list of available lists.\n\n</td></tr><tr><td>\n\nAdvanced\n\n</td><td>\n\nSelect this check box to use JavaScript in place of the **Applies to table** and **Queries from table** fields.\n\n</td></tr><tr><td>\n\nApplies to table\n\n</td><td>\n\nSelect the table on which the related list appears. For example, to add a related list to the user form, select the User \\[sys\\_user\\] table.\n\nThis field is hidden in Advanced relationship records.\n\n</td></tr><tr><td>\n\nQueries from table\n\n</td><td>\n\nSelect the table from which this related list retrieves data. For example, to add related task records to the related list, select the Task \\[task\\] table.\n\nThis field is hidden in Advanced relationship records.\n\n</td></tr><tr><td>\n\nApply to\n\n</td><td>\n\nType a script that sets the *answer* variable to **true** when a user opens a form on the desired table. This field is only visible with the **Advanced** check box selected.\n\n</td></tr><tr><td>\n\nQuery from\n\n</td><td>\n\nType a script that sets the *answer* variable to the name of the table from which the related list retrieves data. This field is only visible with the **Advanced** check box selected.\n\n</td></tr><tr><td>\n\nQuery with\n\n</td><td>\n\nSpecify the records to include by typing a script.For example:\n\n```\ncurrent.addQuery('opened_by', parent.sys_id);\n```\n\n-   The `current` object specifies the current record on which the script is triggered.\n-   The `addQuery` method adds a filter that returns records meeting a specified condition.\n-   The `opened_by` variable is the field name you're querying in the table from **Queries from table**.\n-   The `parent.sys_id` variable refers to the **Applies to table** and the ID of the record being displayed.\n\n\n</td></tr><tr><td>\n\nInsert Callback\n\n</td><td>\n\nType a script to run after a successful insert action. This field is only visible with the **Advanced** check box selected.\n\n</td></tr></tbody>\n</table>4.  Click **Submit**.\n\n\n-   **[Add incidents by same caller related list](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-user-interface/t_ExampleIncidentsBySameCaller.md)**  \nThis example adds the existing relationship, Incidents by Same Caller, to incident forms.\n-   **[Add transactions by user related list](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-user-interface/t_ExampleTransactionsByUser.md)**  \nThis example adds a relationship, Last 20 transactions, to the user form.\n\n**Parent Topic:**[Related lists](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-user-interface/c_RelatedLists.md)\n\n**Related topics**  \n\n\n[Select or create records in a related list]()\n\n[Configure when a related list loads]()\n\n[Create a default filter for a related list]()\n\n[Configure the edit option]()\n\n[Add fields to selections in a related list]()\n\n[Create a default filter for list selector records]()\n\n"}}