---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# GlideList2 (g_list) - Client

# GlideList2 (g_list) - Client {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 8 minutes to read

The GlideList2 API provides methods to customize (v2) lists.

The variable `g_list` is used to access a specified list object. The
`g_list` variable is not available to the related lists form link UI action.
It is available to the lists form link UI action.

These methods are used in UI context menus and UI actions.

Several of these methods are available in Next Experience UI Framework. For details, see
[GlideList (Next Experience UI Framework)](https://servicenow-prod.fluidtopics.net/M_B3s_ODNuFgKelweNBx2w#GlideListClientAPINEx "The GlideList API provides methods to customize lists in the Next Experience UI Framework.").

## GlideList2 - addFilter(String filter) {#ariaid-title2}

Adds a single term to the list query filter.
{#r_GL2-addFilter_S__table_sgz_zpw_15__entry__3}{#r_GL2-addFilter_S__gList_parmDesc_filter}

| Name | Type | Description |
|-|-|-|
| filter | String | Encoded query string in standard Glide format. See [Encoded query strings](https://www.servicenow.com/docs/access?context=c_EncodedQueryStrings&version=xanadu&pubname=xanadu-platform-user-interface&ft:locale=en-US). |
[Table 1. Parameters]

{#r_GL2-addFilter_S__table_sgz_zpw_15} {#r_GL2-addFilter_S__table_tgz_zpw_15__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 2. Returns]

{#r_GL2-addFilter_S__table_tgz_zpw_15}  

    g_list.addFilter("active=true");

## GlideList2 - get(Object DOMelement) {#ariaid-title3}

Returns the GlideList2 object for the list that contains the specified
item.
{#r_GL2-get_O__table_ugz_zpw_15__entry__3}

| Name | Type | Description |
|-|-|-|
| DOMelement | Object | The DOM element ID for the list for which you want the GlideList2 object. |
[Table 3. Parameters]

{#r_GL2-get_O__table_ugz_zpw_15} {#r_GL2-get_O__table_vgz_zpw_15__entry__2}

| Type | Description |
|-|-|
| Object | The GlideList2 object or null if not found. |
[Table 4. Returns]

{#r_GL2-get_O__table_vgz_zpw_15}

## GlideList2 - get(String ListID) {#ariaid-title4}

Returns the GlideList2 object for the list specified.
{#r_GL2-get_S__table_ugz_zpw_15__entry__3}

| Name | Type | Description |
|-|-|-|
| ListID | String | The list ID for which you want the GlideList2 object. |
[Table 5. Parameters]

{#r_GL2-get_S__table_ugz_zpw_15} {#r_GL2-get_S__table_vgz_zpw_15__entry__2}

| Type | Description |
|-|-|
| Object | The GlideList2 object or null if not found. |
[Table 6. Returns]

{#r_GL2-get_S__table_vgz_zpw_15}  

    function assignLabelActionViaLookupModal(tableName, listId) {
    	var list = GlideList2.get(listId);
    	if (!list)
    		return;

    	assignLabelViaLookup(tableName, sysIds, list.getView());
    }

## GlideList2 - getChecked() {#ariaid-title5}

Returns a comma-separated list of the sys_ids for the items that are checked in the associated list.
{#r_GL2-getChecked__table_wgz_zpw_15__entry__3}

| Name | Type | Description |
|-|-|-|
| none |   |   |
[Table 7. Parameters]

{#r_GL2-getChecked__table_wgz_zpw_15} {#r_GL2-getChecked__table_xgz_zpw_15__entry__2}

| Type | Description |
|-|-|
| 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. |
[Table 8. Returns]

{#r_GL2-getChecked__table_xgz_zpw_15}  

    function removeLabelActionViaLookupModal(tableName, listId) {
      var list = GlideList2.get(listId);
      if (!list)
        return;

      var sysIds = list.getChecked();
      if (!sysIds)
        return;

      removeLabelViaLookup(tableName, sysIds);
    }

## GlideList2 - getFixedQuery() {#ariaid-title6}

Returns the fixed query.
A fixed query is the part of the query that cannot be removed from the breadcrumb (i.e., it is fixed for the user). It is specified by including a
sysparm_fixed_query parameter for the application
module.{#r_GL2-getFixedQuery__gList_ph_getFixedQuery}
{#r_GL2-getFixedQuery__table_ygz_zpw_15__entry__3}

| Name | Type | Description |
|-|-|-|
| none |   |   |
[Table 9. Parameters]

{#r_GL2-getFixedQuery__table_ygz_zpw_15} {#r_GL2-getFixedQuery__table_zgz_zpw_15__entry__2}

| Type | Description |
|-|-|
| String | The fixed query string for the list. |
[Table 10. Returns]

{#r_GL2-getFixedQuery__table_zgz_zpw_15}  

    var list = GlideList2.get(container.readAttribute('list_id'));
    var filter = this._getFilter(element);
    var fixedQuery = list.getFixedQuery();
    if (fixedQuery)
      filter = fixedQuery + "^" + filter;

## GlideList2 - getGroupBy() {#ariaid-title7}

Returns the field or comma-separated list of fields that are used to group the list.
{#r_GL2-getGroupBy__table_ahz_zpw_15__entry__3}

| Name | Type | Description |
|-|-|-|
| none |   |   |
[Table 11. Parameters]

{#r_GL2-getGroupBy__table_ahz_zpw_15} {#r_GL2-getGroupBy__table_bhz_zpw_15__entry__2}

| Type | Description |
|-|-|
| String | The field or comma-separated list of fields that are used to group the list. |
[Table 12. Returns]

{#r_GL2-getGroupBy__table_bhz_zpw_15}  

    function runFilterV2Lists(name, filter) {
      var list = GlideList2.get(name);	
        if (list) {
          var groupBy = list.getGroupBy();
          if (groupBy)  
            filter += "^" + groupBy;
    		
            list.setFilterAndRefresh(filter);
        }
    }

## GlideList2 - getListName() {#ariaid-title8}

Returns the name of the list, which is usually the table name.
{#r_GL2-getListName__table_chz_zpw_15__entry__3}

| Name | Type | Description |
|-|-|-|
| none |   |   |
[Table 13. Parameters]

{#r_GL2-getListName__table_chz_zpw_15} {#r_GL2-getListName__table_dhz_zpw_15__entry__2}

| Type | Description |
|-|-|
| String | The list name (usually the table name). |
[Table 14. Returns]

{#r_GL2-getListName__table_dhz_zpw_15}  

    var list = GlideList2.get(name);	
    var listName = list.getListName();

## GlideList2 - getOrderBy() {#ariaid-title9}

Returns the first field used to order the list.
{#r_GL2-getOrderBy__table_qs2_nww_15__entry__3}

| Name | Type | Description |
|-|-|-|
| none |   |   |
[Table 15. Parameters]

{#r_GL2-getOrderBy__table_qs2_nww_15} {#r_GL2-getOrderBy__table_rs2_nww_15__entry__2}

| Type | Description |
|-|-|
| String | The field by which to order the list. Empty if the list is not ordered. |
[Table 16. Returns]

{#r_GL2-getOrderBy__table_rs2_nww_15}  

    var list = GlideList2.get(listId);
    if (!list)
      return;
    var orderBy = list.getOrderBy();

## GlideList2 - getParentTable() {#ariaid-title10}

Returns the name of the parent table for a related list (the table associated with the form).
{#r_GL2-getParentTable__table_ss2_nww_15__entry__3}

| Name | Type | Description |
|-|-|-|
| none |   |   |
[Table 17. Parameters]

{#r_GL2-getParentTable__table_ss2_nww_15} {#r_GL2-getParentTable__table_ts2_nww_15__entry__2}

| Type | Description |
|-|-|
| String | The parent table name. |
[Table 18. Returns]

{#r_GL2-getParentTable__table_ts2_nww_15}  

    for (var id in GlideLists2) {
      var list = GlideLists2[id];
      if (list.getTableName() == listTableName && list.getParentTable() == tableName)
        return list.getContainer();
    }

## GlideList2 - getQuery(Boolean orderBy, Boolean groupBy, Boolean fixed, Boolean all) {#ariaid-title11}

Returns the encoded query string for the list.
{#r_GL2-getQuery_B_B_B_B__table_us2_nww_15__entry__3}{#r_GL2-getQuery_B_B_B_B__gList_parmDesc_orderByB}{#r_GL2-getQuery_B_B_B_B__gList_parmDesc_groupByB}{#r_GL2-getQuery_B_B_B_B__gList_parmDesc_fixed}{#r_GL2-getQuery_B_B_B_B__gList_parmDesc_all}

| Name | Type | Description |
|-|-|-|
| orderBy | Boolean | Optional. Flag that indicates whether to include orderBy in results. Valid values: * true: Include orderBy in results. * false: Do not include orderBy in results. {#r_GL2-getQuery_B_B_B_B__ul_awp_k1n_vrb} Default: false |
| groupBy | Boolean | Optional. Flag that indicates whether to include groupBy in results. Valid values: * true: Include groupBy in results. * false: Do not include groupBy in results. {#r_GL2-getQuery_B_B_B_B__ul_gpz_21n_vrb} Default: false |
| fixed | Boolean | Optional. Flag that indicates whether to include fixed query in results. Valid values: * true: Include fixed query in results. * false: Do not include fixed query in results. {#r_GL2-getQuery_B_B_B_B__ul_e5s_11n_vrb} Default: false |
| all | Boolean | Default. Flag that indicates whether to include orderBy, groupBy, and fixed query in results. Valid values: * true: Include orderBy, groupBy, and fixed query in results. * false: Do not include all three options in results. {#r_GL2-getQuery_B_B_B_B__ul_ovz_pzm_vrb} Default: true |
[Table 19. Parameters]

{#r_GL2-getQuery_B_B_B_B__table_us2_nww_15} {#r_GL2-getQuery_B_B_B_B__table_vs2_nww_15__entry__2}

| Type | Description |
|-|-|
| String | Encoded query string for the list. |
[Table 20. Returns]

{#r_GL2-getQuery_B_B_B_B__table_vs2_nww_15}  

    var list = GlideList2.get(this.listID);
    var ajax = new GlideAjax("AJAXJellyRunner", "AJAXJellyRunner.do");
      ajax.addParam("sysparm_query_encoded", list.getQuery({groupby: true, orderby: true}));
      ajax.addParam("sysparm_table", list.getTableName());
      ajax.addParam("sysparm_view", list.getView());

## GlideList2 - getRelated() {#ariaid-title12}

Returns the related list field that associates the related list to the parent form.
{#r_GL2-getRelated__table_ws2_nww_15__entry__3}

| Name | Type | Description |
|-|-|-|
| none |   |   |
[Table 21. Parameters]

{#r_GL2-getRelated__table_ws2_nww_15} {#r_GL2-getRelated__table_xs2_nww_15__entry__2}

| Type | Description |
|-|-|
| String | Field that connects the list to the parent form. |
[Table 22. Returns]

{#r_GL2-getRelated__table_xs2_nww_15}  

    var list = GlideList2.get(name);
    var related = list.getRelated();
    if (related) 
      ajax.addParam("sysparm_is_related_list", "true");

## GlideList2 - getTableName() {#ariaid-title13}

Returns the table name for the list.
{#r_GL2-getTableName__table_ys2_nww_15__entry__3}

| Name | Type | Description |
|-|-|-|
| none |   |   |
[Table 23. Parameters]

{#r_GL2-getTableName__table_ys2_nww_15} {#r_GL2-getTableName__table_zs2_nww_15__entry__2}

| Type | Description |
|-|-|
| String | Returns the table name for the list. |
[Table 24. Returns]

{#r_GL2-getTableName__table_zs2_nww_15}  

    GlideList2.getListsForTable = function(table) {
        var lists = [];
        for (var id in GlideLists2) {
            var list = GlideLists2[id];
            if (list.getTableName() == table)
                lists.push(list);
        }
        return lists;
    }

## GlideList2 - getView() {#ariaid-title14}

Returns the view used to display the list.
{#r_GL2-getView__table_llc_vmx_15__entry__3}

| Name | Type | Description |
|-|-|-|
| none |   |   |
[Table 25. Parameters]

{#r_GL2-getView__table_llc_vmx_15} {#r_GL2-getView__table_mlc_vmx_15__entry__2}

| Type | Description |
|-|-|
| String | The name of the view. |
[Table 26. Returns]

{#r_GL2-getView__table_mlc_vmx_15}  

    function assignLabelActionViaLookupModal(tableName, listId) {
    	var list = GlideList2.get(listId);
    	if (!list)
    		return;

    	assignLabelViaLookup(tableName, sysIds, list.getView());
    }

## GlideList2 - getTitle() {#ariaid-title15}

Returns the list title.
{#r_GL2-getTitle__table_at2_nww_15__entry__3}

| Name | Type | Description |
|-|-|-|
| none |   |   |
[Table 27. Parameters]

{#r_GL2-getTitle__table_at2_nww_15} {#r_GL2-getTitle__table_bt2_nww_15__entry__2}

| Type | Description |
|-|-|
| String | The list title. |
[Table 28. Returns]

{#r_GL2-getTitle__table_bt2_nww_15}  

    var list = GlideList2.get(name);	
    var listTitle = list.getTitle();

## GlideList2 - isUserList() {#ariaid-title16}

Returns true if the list has been personalized by the user by
choosing the list mechanic and changing the list layout.
{#r_GL2-isUserList__table_nlc_vmx_15__entry__3}

| Name | Type | Description |
|-|-|-|
| none |   |   |
[Table 29. Parameters]

{#r_GL2-isUserList__table_nlc_vmx_15} {#r_GL2-isUserList__table_olc_vmx_15__entry__2}

| Type | Description |
|-|-|
| Boolean | True if the list layout has been changed. |
[Table 30. Returns]

{#r_GL2-isUserList__table_olc_vmx_15}  

    var list = GlideList2.get(listId);
    if (!list)
      return;
    if (list.isUserList())
      var tableName = list.getTableName();

## GlideList2 - refresh(Number firstRow, String additionalParms) {#ariaid-title17}

Refreshes the list. The orderBy part of the list filter is ignored so that the list uses its natural ordering when it is refreshed.
{#r_GL2-refresh_N_S__table_plc_vmx_15__entry__3}{#r_GL2-refresh_N_S__gList_parmDesc_firstRowN}{#r_GL2-refresh_N_S__gList_parmDesc_addtl}

| Name | Type | Description |
|-|-|-|
| firstRow | Number | The first row to appear in the list. Default: First row of the current view. |
| additionalParms | String | Optional name-value pairs that are submitted with the list refresh request. |
[Table 31. Parameters]

{#r_GL2-refresh_N_S__table_plc_vmx_15} {#r_GL2-refresh_N_S__table_qlc_vmx_15__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 32. Returns]

{#r_GL2-refresh_N_S__table_qlc_vmx_15}  

    $timeout(function() {
      if (GlideList.lists) {
        var list = GlideList.get(name);
        if (list) {
           if (sortBy) {
             if (sortDirection == 'ASC')
                list.sort(sortBy);
             else
                list.sortDescending(sortBy);
             }  
           list.refresh();
         }
       }
    }			

## GlideList2 - refreshWithOrderBy(Number firstRow, String description) {#ariaid-title18}

Refreshes the list. The orderBy part of the list filter is included if it is specified for the list.
{#r_GL2-refreshWithOrderBy_N_S__table_rlc_vmx_15__entry__3}{#r_GL2-refreshWithOrderBy_N_S__gList_parmDesc_firstRowN}{#r_GL2-refreshWithOrderBy_N_S__gList_parmDesc_description}

| Name | Type | Description |
|-|-|-|
| firstRow | Number | The first row to appear in the list. Default: First row of the current view. |
| description | String | Optional name-value pairs that are submitted with the list refresh request. |
[Table 33. Parameters]

{#r_GL2-refreshWithOrderBy_N_S__table_rlc_vmx_15} {#r_GL2-refreshWithOrderBy_N_S__table_slc_vmx_15__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 34. Returns]

{#r_GL2-refreshWithOrderBy_N_S__table_slc_vmx_15}  

    ga.getXML(function(serverResponse) {
      var response = serverResponse.responseXML.getElementsByTagName("response")[0];
      if (response) {
        var list = GlideList2.getByName("backlog_stories");
        list.refreshWithOrderBy();
        var status = response.getAttribute('status');
        $j('html, body').animate({scrollTop: $j("#"+data.record.sys_id).offset().top},500);
        if (status == 'failure') {
          alert('${gs.getMessage("Story cannot be created. Team is not associated with any project.")}');
        }
      }
    }

## GlideList2 - setFilter(String filter) {#ariaid-title19}

Sets the encoded query string for the list, ignoring the orderBy and groupBy parts of the query string.
{#r_GL2-setFilter_S__table_tlc_vmx_15__entry__3}{#r_GL2-setFilter_S__gList_parmDesc_filter}

| Name | Type | Description |
|-|-|-|
| filter | String | Encoded query string in standard Glide format. See [Encoded query strings](https://www.servicenow.com/docs/access?context=c_EncodedQueryStrings&version=xanadu&pubname=xanadu-platform-user-interface&ft:locale=en-US). |
[Table 35. Parameters]

{#r_GL2-setFilter_S__table_tlc_vmx_15} {#r_GL2-setFilter_S__table_ulc_vmx_15__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 36. Returns]

{#r_GL2-setFilter_S__table_ulc_vmx_15}  

    list = GlideList2.get($(side+"ContentDivRelease").select(".list_div")[0].getAttribute("id"));
    if (list) {
      list.setFilter("active=true");
      list.refresh(1);
     }

## GlideList2 - setFilterAndRefresh(String filter) {#ariaid-title20}

Sets the encoded query string for the list, including the orderBy
and groupBy if specified, and then refreshes the list using the new
filter.
{#r_GL2-setFilterAndRefresh_S__table_vlc_vmx_15__entry__3}

| Name | Type | Description |
|-|-|-|
| filter | String | Encoded query string. |
[Table 37. Parameters]

{#r_GL2-setFilterAndRefresh_S__table_vlc_vmx_15} {#r_GL2-setFilterAndRefresh_S__table_wlc_vmx_15__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 38. Returns]

{#r_GL2-setFilterAndRefresh_S__table_wlc_vmx_15}  

    function updateListFilter(projectID) {
      var list = GlideList2.getByName("backlog_stories");
      var fixedQuery = $('hdn_additional_filters').value;
      if(!projectID) {
          list.setFilterAndRefresh(fixedQuery + "^ORDERBYteam_index");
          list.setOrderBy("team_index");
      }
    }

## GlideList2 - setFirstRow(Number rowNum) {#ariaid-title21}

Sets the first row that appears in the list when the list is refreshed.
{#r_GL2-setFirstRow_N__table_uv1_k4x_15__entry__3}

| Name | Type | Description |
|-|-|-|
| rowNum | Number | Row number of the first row to display. |
[Table 39. Parameters]

{#r_GL2-setFirstRow_N__table_uv1_k4x_15} {#r_GL2-setFirstRow_N__table_vv1_k4x_15__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 40. Returns]

{#r_GL2-setFirstRow_N__table_vv1_k4x_15}  

    var nextRow = 0;
    var rowsPerPage = 20;
    var list = GlideList2.get(listId);
    if (!list)
      return;
    list.setFirstRow(nextRow);
    nextRow = nextRow + rowsPerPage;

## GlideList2 - setGroupBy(String groupBy) {#ariaid-title22}

Sets the list groupBy criteria for a single field.
{#r_GL2-setGroupBy_S__table_wv1_k4x_15__entry__3}{#r_GL2-setGroupBy_S__gList_parmDesc_groupByS}

| Name | Type | Description |
|-|-|-|
| groupBy | String | The groupBy criteria for the list. |
[Table 41. Parameters]

{#r_GL2-setGroupBy_S__table_wv1_k4x_15} {#r_GL2-setGroupBy_S__table_xv1_k4x_15__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 42. Returns]

{#r_GL2-setGroupBy_S__table_xv1_k4x_15}  

    function runContextAction(listId) {
      var g_list = GlideList2.get(listId);
      g_list.setGroupBy('');
      g_list.refresh(1);
    }

## GlideList2 - setOrderBy(String orderBy) {#ariaid-title23}

Sets the orderBy criteria for the list.
For
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.
{#r_GL2-setOrderBy_S__table_yv1_k4x_15__entry__3}{#r_GL2-setOrderBy_S__gList_parmDesc_orderByS}

| Name | Type | Description |
|-|-|-|
| orderBy | String | Single or multiple orderBy fields. |
[Table 43. Parameters]

{#r_GL2-setOrderBy_S__table_yv1_k4x_15} {#r_GL2-setOrderBy_S__table_zv1_k4x_15__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 44. Returns]

{#r_GL2-setOrderBy_S__table_zv1_k4x_15}  

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                updateOrderBy: function(orderBy){
      var list = GlideList2.get(this.listID);
      if (list)
        list.setOrderBy(orderBy);
    };

## GlideList2 - setRowsPerPage(Number rows) {#ariaid-title24}

Sets the number of rows per page to display.
{#r_GL2-setRowsPerPage_N__table_aw1_k4x_15__entry__3}

| Name | Type | Description |
|-|-|-|
| rows | Number | The number of rows to display. |
[Table 45. Parameters]

{#r_GL2-setRowsPerPage_N__table_aw1_k4x_15} {#r_GL2-setRowsPerPage_N__table_bw1_k4x_15__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 46. Returns]

{#r_GL2-setRowsPerPage_N__table_bw1_k4x_15}  

    link: function(scope) {
      var list = GlideList2.get(scope.listId);
      list.setRowsPerPage(scope.maxRows);
      list.setFilterAndRefresh(scope.tableQuery);
    }

## GlideList2 - showHideGroups(Boolean showFlag) {#ariaid-title25}

Shows or hides all the groups within the list and saves the current collapsed/expanded
state of the groups as a user preference.
{#r_GL2-showHideGroups_B__table_cw1_k4x_15__entry__3}

| Name | Type | Description |
|-|-|-|
| showFlag | Boolean | If true, shows the groups within the list. |
[Table 47. Parameters]

{#r_GL2-showHideGroups_B__table_cw1_k4x_15} {#r_GL2-showHideGroups_B__table_dw1_k4x_15__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 48. Returns]

{#r_GL2-showHideGroups_B__table_dw1_k4x_15}  

    function showHideAllGroups(showFlag) {
      var list = GlideList2.get(listId);
      if (!list)
        return;
      list.showHideGroups(showFlag);
    }

## GlideList2 - showHideList(Boolean showFlag) {#ariaid-title26}

Displays or hides the list and saves the current collapsed/expanded state of the list as a user preference.
{#r_GL2-showHideList_B__table_ew1_k4x_15__entry__3}

| Name | Type | Description |
|-|-|-|
| showFlag | Boolean | If true, displays the list. |
[Table 49. Parameters]

{#r_GL2-showHideList_B__table_ew1_k4x_15} {#r_GL2-showHideList_B__table_fw1_k4x_15__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 50. Returns]

{#r_GL2-showHideList_B__table_fw1_k4x_15}  

    GlideList2.toggleAll = function(expandFlag) {
    for (var id in GlideLists2) {
      var list = GlideLists2[id];
    list.showHideList(expandFlag);
    }

## GlideList2 - sort(String field) {#ariaid-title27}

Sorts the list in ascending order and sets the field as an orderBy column.
{#r_GL2-sort_S__table_uks_xpx_15__entry__3}{#r_GL2-sort_S__gList_parmDesc_field}

| Name | Type | Description |
|-|-|-|
| field | String | Field to use to sort the list. |
[Table 51. Parameters]

{#r_GL2-sort_S__table_uks_xpx_15} {#r_GL2-sort_S__table_vks_xpx_15__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 52. Returns]

{#r_GL2-sort_S__table_vks_xpx_15}  

    $timeout(function() {
      if (GlideList.lists) {
        var list = GlideList.get(name);
        if (list) {
           if (sortBy) {
             if (sortDirection == 'ASC')
                list.sort(sortBy);
             else
                list.sortDescending(sortBy);
             }  
           list.refresh();
         }
       }
    }

## GlideList2 - sortDescending(String field, Number amount) {#ariaid-title28}

Sorts a single field in the list in descending order and sets the field as an orderByDescField column.
{#r_GL2-sortDescending_S_N__table_wks_xpx_15__entry__3}

| Name | Type | Description |
|-|-|-|
| field | String | Field to use to sort the list. |
[Table 53. Parameters]

{#r_GL2-sortDescending_S_N__table_wks_xpx_15} {#r_GL2-sortDescending_S_N__table_xks_xpx_15__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 54. Returns]

{#r_GL2-sortDescending_S_N__table_xks_xpx_15}  

    $timeout(function() {
      if (GlideList.lists) {
        var list = GlideList.get(name);
        if (list) {
           if (sortBy) {
             if (sortDirection == 'ASC')
                list.sort(sortBy);
             else
                list.sortDescending(sortBy);
             }  
           list.refresh();
         }
       }
    }

## GlideList2 - toggleList() {#ariaid-title29}

Toggles the display of the list and saves the current collapsed/expanded state of the list as a user preference.
{#r_GL2-toggleList__table_yks_xpx_15__entry__3}

| Name | Type | Description |
|-|-|-|
| none |   |   |
[Table 55. Parameters]

{#r_GL2-toggleList__table_yks_xpx_15} {#r_GL2-toggleList__table_zks_xpx_15__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 56. Returns]

{#r_GL2-toggleList__table_zks_xpx_15}  

    var list = GlideList2.get(listId);
    if (!list)
      return;
    list.toggleList();

## GlideList2 - toggleListNoPref() {#ariaid-title30}

Toggles the display of the list but does not save the current collapsed/expanded state of the list as a user preference.
{#r_GL2-toggleListNoPref__table_als_xpx_15__entry__3}

| Name | Type | Description |
|-|-|-|
| none |   |   |
[Table 57. Parameters]

{#r_GL2-toggleListNoPref__table_als_xpx_15} {#r_GL2-toggleListNoPref__table_bls_xpx_15__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 58. Returns]

{#r_GL2-toggleListNoPref__table_bls_xpx_15}  

    var list = GlideList2.get(listId);
    if (!list)
      return;
    list.toggleListNoPref();


