{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":160,"path":"api-reference/GlideListClientAPINEx.md","title":"GlideList \\(Next Experience\\) - Client","bundle":null,"doc_type":null,"release":"australia","body":"\n# GlideList \\(Next Experience\\) - Client\n\nThe GlideList API provides methods to customize lists in the Next Experience UI Framework.\n\nThis API enables adding GlideList functionality to a button in the Workspace Experience UI. Use the `g_list` variable to call each method.\n\nTo add a button, create a list action and add GlideList method calls into the **Client Script** field `onClick{}` method. For instructions, see [Use the client GlideList API in the Workspace Experience UI](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/developer-guides/add-api-glide.md).\n\n\\[Omitted image \"add-api-glidelist-workspace.png\"\\] Alt text: GlideList method calls in the Client Script field.\n\n**Note:** Each method must be used with the refresh\\(\\) method, with the exceptions of sort\\(\\) and sortDescending\\(\\) methods.\n\nThe methods in this API are based on [GlideList2](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/c_GlideList2API.md). The following GlideList2 methods are not supported in the Next Experience framework and cause an error in the console log:\n\n-   isUserList\\(\\)\n-   setFirstRow\\(\\)\n-   showHideGroups\\(\\)\n-   showHideList\\(\\)\n-   toggleList\\(\\)\n-   toggleListNoPref\\(\\)\n\n**Parent Topic:**[Client Next Experience API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/api-client-next.md)\n\n## GlideList \\(Next Experience\\) - addFilter\\(String filter\\)\n\nAdds a single term to the list query filter.\n\nSee also [setFilter\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideListClientAPINEx.md).\n\n|Name|Type|Description|\n|----|----|-----------|\n|filter|String|Encoded query string in standard Glide format. See [Encoded query strings](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-user-interface/c_EncodedQueryStrings.md).|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example shows how to retrieve a list of active records and refresh the page.\n\n```\ng_list.addFilter(\"active=true\");\ng_list.refresh();\n```\n\n## GlideList \\(Next Experience\\) - getChecked\\(\\)\n\nReturns a comma-separated list of the sys\\_ids for the items that are checked in the associated list.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|Comma-separated list of the sys\\_ids for the items that are checked in the list. Does not check to determine that the items returned are allowed to be executed.|\n\nThe following example shows how to get the sys\\_ids of each record selected in a list.\n\n```\nvar myChecked = g_list.getChecked();\nalert(myChecked);\ng_list.refresh();\n```\n\nOutput in an alert box \\(empty if no records are selected\\):\n\n```\n079893e6b733330059128ac7ee11a967, 4fca6d45b7131010f03e9b7ade11a9d3, 5c460fbf1bd0011079e52131604bcbd9\n```\n\n## GlideList \\(Next Experience\\) - getFixedQuery\\(\\)\n\nReturns the fixed query.\n\nA fixed query is the part of the query that cannot be removed from the breadcrumb \\(i.e., it is fixed for the user\\).\n\nApply this method under **Related List Actions** in the Workspace Experience UI. For instructions, see [Use the client GlideList API in the Workspace Experience UI](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/developer-guides/add-api-glide.md).\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|The fixed query string for the list.|\n\nThe following example shows how to display a fixed query with a debug message in the browser console log.\n\n```\nconsole.log(g_list.getFixedQuery() + \" debug message\");\n```\n\nThe output after clicking the button on the Child Incidents tab in an Incident record.\n\n```\nparent_incident=46f1784ba9fe19810018aa27fbb23482 debug message\n```\n\n## GlideList \\(Next Experience\\) - getGroupBy\\(\\)\n\nReturns the field or comma-separated list of fields that are used to group the list.\n\nSee also:\n\n-   [getQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideListClientAPINEx.md)\n-   [setGroupBy\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideListClientAPINEx.md)\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|The field or comma-separated list of fields that are used to group the list.|\n\nThe following example shows how to get field groupBy values of the current list view.\n\n```\nvar grpdBy = g_list.getGroupBy();\nalert(\"The list is grouped by \" + grpdBy);\ng_list.refresh();\n```\n\nOutput in an alert box for a list grouped by priority:\n\n```\nThe list is grouped by ^GROUPBYpriority\n```\n\n## GlideList \\(Next Experience\\) - getListName\\(\\)\n\nReturns the name of the list, which is usually the table name.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|The list name \\(usually the table name\\).|\n\nThe following example shows how to call the method.\n\n```\ng_list.getListName();\n```\n\n## GlideList \\(Next Experience\\) - getOrderBy\\(\\)\n\nReturns the first field used to order the list.\n\nSee also:\n\n-   [getQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideListClientAPINEx.md)\n-   [setOrderBy\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideListClientAPINEx.md)\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|The field by which to order the list. Empty if the list is not ordered.|\n\nThe following example shows how to get field orderBy values of the current list view.\n\n```\nvar orderBy = g_list.getOrderBy();\n\t\nalert(\"The list is ordered by \" + orderBy);\ng_list.refresh();\n```\n\nOutput in an alert box for a list ordered by priority:\n\n```\nThe list is ordered by ^ORDERBYDESCpriority\n```\n\n## GlideList \\(Next Experience\\) - getParentTable\\(\\)\n\nReturns the name of the parent table for a related list \\(the table associated with the form\\).\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|The parent table name.|\n\nThe following example shows how to call the method.\n\n```\ng_list.getParentTable();\ng_list.refresh();\n```\n\n## GlideList \\(Next Experience\\) - getQuery\\(Object\\)\n\nReturns the encoded query string for the list.\n\nSee also:\n\n-   [getFixedQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideListClientAPINEx.md)\n-   [getGroupBy\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideListClientAPINEx.md)\n-   [getOrderBy\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideListClientAPINEx.md)\n-   [setGroupBy\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideListClientAPINEx.md)\n-   [setOrderBy\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideListClientAPINEx.md)\n\n<table id=\"table_us2_nww_15\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\n&lt;object&gt;\n\n</td><td>\n\nObject\n\n</td><td>\n\nOptional. By default, this method includes orderBy, groupBy, and fixed query in the results. You can set object properties to restrict results to one or more of the three available options.\n\n</td></tr><tr><td>\n\n&lt;object&gt;.orderBy\n\n</td><td>\n\nBoolean\n\n</td><td>\n\nOptional. Flag that indicates whether to include orderBy in results.Valid values:\n\n-   true: Include orderBy in results.\n-   false: Do not include orderBy in results.\n\n Default: false\n\n</td></tr><tr><td>\n\n&lt;object&gt;.groupBy\n\n</td><td>\n\nBoolean\n\n</td><td>\n\nOptional. Flag that indicates whether to include groupBy in results.Valid values:\n\n-   true: Include groupBy in results.\n-   false: Do not include groupBy in results.\n\n Default: false\n\n</td></tr><tr><td>\n\n&lt;object&gt;.fixed\n\n</td><td>\n\nBoolean\n\n</td><td>\n\nOptional. Flag that indicates whether to include fixed query in results.Valid values:\n\n-   true: Include fixed query in results.\n-   false: Do not include fixed query in results.\n\n Default: false\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|String|Encoded query string for the list.|\n\nThe following example shows how to display the list encoded query with a debug message in the browser console log.\n\n```\nvar myQuery = g_list.getQuery();\nconsole.log(myQuery + \" message\");\n```\n\nOutput:\n\n```\nactive=false^EQ message\n```\n\n## GlideList \\(Next Experience\\) - getRelated\\(\\)\n\nReturns the related list field that associates the related list to the parent form.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|Field that connects the list to the parent form.|\n\nThe following example shows how to call the method.\n\n```\ng_list.getRelated();\n```\n\n## GlideList \\(Next Experience\\) - getTableName\\(\\)\n\nReturns the table name for the list.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|Returns the table name for the list.|\n\nThe following example shows how to display the list name for the current view.\n\n```\nvar listName = g_list.getListName();\nalert(\"The current list name is \" + listName);\ng_list.refresh();\n```\n\nOutput in an alert box:\n\n```\nThe current list name is incident\n```\n\n## GlideList \\(Next Experience\\) - getTitle\\(\\)\n\nReturns the list title.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|The list title.|\n\nThe following example shows how to call the method.\n\n```\ng_list.getTitle();\n```\n\n## GlideList \\(Next Experience\\) - getView\\(\\)\n\nReturns the view used to display the list.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|The name of the view.|\n\nThe following example shows how to call the method.\n\n```\ng_list.getView();\n```\n\n## GlideList \\(Next Experience\\) - refresh\\(Number firstRow\\)\n\nRefreshes the list. The **orderBy** part of the list filter is ignored so that the list uses its natural ordering when it is refreshed.\n\n<table id=\"table_plc_vmx_15\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfirstRow\n\n</td><td>\n\nNumber\n\n</td><td id=\"gList_parmDesc_firstRowN\">\n\nThe first row to appear in the list.Default: First row of the current view.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example shows how to call the method.\n\n```\ng_list.addFilter(\"active=true\");\ng_list.refresh();\n```\n\n## GlideList \\(Next Experience\\) - refreshWithOrderBy\\(Number firstRow\\)\n\nRefreshes the list. The **orderBy** part of the list filter is included if it is specified for the list.\n\n<table id=\"table_rlc_vmx_15\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfirstRow\n\n</td><td>\n\nNumber\n\n</td><td id=\"gList_parmDesc_firstRowN\">\n\nThe first row to appear in the list.Default: First row of the current view.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example shows how to call the method.\n\n```\ng_list.refreshWithOrderBy();\n```\n\n## GlideList \\(Next Experience\\) - setFilter\\(String filter\\)\n\nSets the encoded query string for the list, ignoring the **orderBy** and **groupBy** parts of the query string.\n\nSee also [addFilter\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideListClientAPINEx.md).\n\n|Name|Type|Description|\n|----|----|-----------|\n|filter|String|Encoded query string in standard Glide format. See [Encoded query strings](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-user-interface/c_EncodedQueryStrings.md).|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example shows how to restrict list results to active records.\n\n```\ng_list.setFilter(\"active=true\");\ng_list.refresh();\n```\n\n## GlideList \\(Next Experience\\) - setGroupBy\\(String groupBy\\)\n\nSets the list **groupBy** criteria for a single field.\n\nSee also:\n\n-   [getGroupBy\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideListClientAPINEx.md)\n-   [getQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideListClientAPINEx.md)\n\n|Name|Type|Description|\n|----|----|-----------|\n|groupBy|String|The **groupBy** criteria for the list.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example shows how to group listed records by Caller ID.\n\n```\ng_list.setGroupBy(\"caller_id\");\ng_list.refresh();\n```\n\n## GlideList \\(Next Experience\\) - setOrderBy\\(String orderBy\\)\n\nSets the **orderBy** criteria for the list.\n\nFor a single order by field, use **orderBy** field or **orderByDesc** field. For multiple fields, use `orderByField1^orderByField2^orderByField3`. **orderBy** specifies ascending order and orderByDesc specifies descending. These prefix strings are optional. If not specified, **orderBy** is the default order.\n\nSee also:\n\n-   [getOrderBy\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideListClientAPINEx.md)\n-   [getQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideListClientAPINEx.md)\n-   [sort\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideListClientAPINEx.md)\n-   [sortDescending\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideListClientAPINEx.md)\n\n|Name|Type|Description|\n|----|----|-----------|\n|orderBy|String|Single or multiple orderBy fields.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example shows how to order the list by the value of the Priority field.\n\n```\ng_list.setOrderBy(\"priority\");\ng_list.refresh();\n```\n\n## GlideList \\(Next Experience\\) - setRowsPerPage\\(Number rows\\)\n\nSets the number of rows per page to display.\n\n|Name|Type|Description|\n|----|----|-----------|\n|rows|Number|The number of rows to display.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example shows how to limit results to 50 rows per page.\n\n```\ng_list.setRowsPerPage(50);\nrefresh();\n```\n\n## GlideList \\(Next Experience\\) - sort\\(String field\\)\n\nSorts the list in ascending order and sets the field as an **orderBy** column.\n\nSee also:\n\n-   [getOrderBy\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideListClientAPINEx.md)\n-   [getQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideListClientAPINEx.md)\n-   [setOrderBy\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideListClientAPINEx.md)\n-   [sortDescending\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideListClientAPINEx.md)\n\n**Note:** This method does not require the refresh\\(\\) method.\n\n|Name|Type|Description|\n|----|----|-----------|\n|field|String|Field to use to sort the list.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example shows how to sort results by the **Number** field.\n\n```\ng_list.sort(\"number\");\n```\n\n## GlideList \\(Next Experience\\) - sortDescending\\(String field, Number amount\\)\n\nSorts a single field in the list in descending order and sets the field as an **orderByDescField** column.\n\nSee also:\n\n-   [getOrderBy\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideListClientAPINEx.md)\n-   [getQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideListClientAPINEx.md)\n-   [setOrderBy\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideListClientAPINEx.md)\n-   [sortDescending\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideListClientAPINEx.md)\n\n**Note:** This method does not require the refresh\\(\\) method.\n\n|Name|Type|Description|\n|----|----|-----------|\n|field|String|Field to use to sort the list.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example shows how to sort results by the Number field in descending order.\n\n```\ng_list.sortDescending(\"number\");\n```\n\n"}}