Skip to content
Release: Australia · Updated: 2026-03-12 · Official documentation · View source

GlideList2 (g_list)- Client

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).

Parent Topic:Client API reference

GlideList2 - addFilter(String filter)

Adds a single term to the list query filter.

NameTypeDescription
filterStringEncoded query string in standard Glide format. See Encoded query strings.
TypeDescription
void 
g_list.addFilter("active=true");

GlideList2 - get(Object DOMelement)

Returns the GlideList2 object for the list that contains the specified item.

NameTypeDescription
DOMelementObjectThe DOM element ID for the list for which you want the GlideList2 object.
TypeDescription
ObjectThe GlideList2 object or null if not found.

GlideList2 - get(String ListID)

Returns the GlideList2 object for the list specified.

NameTypeDescription
ListIDStringThe list ID for which you want the GlideList2 object.
TypeDescription
ObjectThe GlideList2 object or null if not found.
function assignLabelActionViaLookupModal(tableName, listId) {
    var list = GlideList2.get(listId);
    if (!list)
        return;

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

GlideList2 - getChecked()

Returns a comma-separated list of the sys_ids for the items that are checked in the associated list.

NameTypeDescription
none  
TypeDescription
StringComma-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.
function removeLabelActionViaLookupModal(tableName, listId) {
  var list = GlideList2.get(listId);
  if (!list)
    return;

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

  removeLabelViaLookup(tableName, sysIds);
}

GlideList2 - getFixedQuery()

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.

NameTypeDescription
none  
TypeDescription
StringThe fixed query string for the list.
var list = GlideList2.get(container.readAttribute('list_id'));
var filter = this._getFilter(element);
var fixedQuery = list.getFixedQuery();
if (fixedQuery)
  filter = fixedQuery + "^" + filter;

GlideList2 - getGroupBy()

Returns the field or comma-separated list of fields that are used to group the list.

NameTypeDescription
none  
TypeDescription
StringThe field or comma-separated list of fields that are used to group the list.
function runFilterV2Lists(name, filter) {
  var list = GlideList2.get(name);  
    if (list) {
      var groupBy = list.getGroupBy();
      if (groupBy)  
        filter += "^" + groupBy;

        list.setFilterAndRefresh(filter);
    }
}

GlideList2 - getListName()

Returns the name of the list, which is usually the table name.

NameTypeDescription
none  
TypeDescription
StringThe list name (usually the table name).
var list = GlideList2.get(name);    
var listName = list.getListName();

GlideList2 - getOrderBy()

Returns the first field used to order the list.

NameTypeDescription
none  
TypeDescription
StringThe field by which to order the list. Empty if the list is not ordered.
var list = GlideList2.get(listId);
if (!list)
  return;
var orderBy = list.getOrderBy();

GlideList2 - getParentTable()

Returns the name of the parent table for a related list (the table associated with the form).

NameTypeDescription
none  
TypeDescription
StringThe parent table name.
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)

Returns the encoded query string for the list.

NameTypeDescription
orderByBooleanOptional. Flag that indicates whether to include orderBy in results.Valid values: - true: Include orderBy in results. - false: Do not include orderBy in results. Default: false
groupByBooleanOptional. Flag that indicates whether to include groupBy in results.Valid values: - true: Include groupBy in results. - false: Do not include groupBy in results. Default: false
fixedBooleanOptional. 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. Default: false
allBooleanDefault. 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. Default: true
TypeDescription
StringEncoded query string for the list.
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()

Returns the related list field that associates the related list to the parent form.

NameTypeDescription
none  
TypeDescription
StringField that connects the list to the parent form.
var list = GlideList2.get(name);
var related = list.getRelated();
if (related) 
  ajax.addParam("sysparm_is_related_list", "true");

GlideList2 - getTableName()

Returns the table name for the list.

NameTypeDescription
none  
TypeDescription
StringReturns the table name for the list.
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()

Returns the view used to display the list.

NameTypeDescription
none  
TypeDescription
StringThe name of the view.
function assignLabelActionViaLookupModal(tableName, listId) {
    var list = GlideList2.get(listId);
    if (!list)
        return;

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

GlideList2 - getTitle()

Returns the list title.

NameTypeDescription
none  
TypeDescription
StringThe list title.
var list = GlideList2.get(name);    
var listTitle = list.getTitle();

GlideList2 - isUserList()

Returns true if the list has been personalized by the user by choosing the list mechanic and changing the list layout.

NameTypeDescription
none  
TypeDescription
BooleanTrue if the list layout has been changed.
var list = GlideList2.get(listId);
if (!list)
  return;
if (list.isUserList())
  var tableName = list.getTableName();

GlideList2 - refresh(Number firstRow, String additionalParms)

Refreshes the list. The orderBy part of the list filter is ignored so that the list uses its natural ordering when it is refreshed.

NameTypeDescription
firstRowNumberThe first row to appear in the list.Default: First row of the current view.
additionalParmsStringOptional name-value pairs that are submitted with the list refresh request.
TypeDescription
void 
$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)

Refreshes the list. The orderBy part of the list filter is included if it is specified for the list.

NameTypeDescription
firstRowNumberThe first row to appear in the list.Default: First row of the current view.
descriptionStringOptional name-value pairs that are submitted with the list refresh request.
TypeDescription
void 
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)

Sets the encoded query string for the list, ignoring the orderBy and groupBy parts of the query string.

NameTypeDescription
filterStringEncoded query string in standard Glide format. See Encoded query strings.
TypeDescription
void 
list = GlideList2.get($(side+"ContentDivRelease").select(".list_div")[0].getAttribute("id"));
if (list) {
  list.setFilter("active=true");
  list.refresh(1);
 }

GlideList2 - setFilterAndRefresh(String filter)

Sets the encoded query string for the list, including the orderBy and groupBy if specified, and then refreshes the list using the new filter.

NameTypeDescription
filterStringEncoded query string.
TypeDescription
void 
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)

Sets the first row that appears in the list when the list is refreshed.

NameTypeDescription
rowNumNumberRow number of the first row to display.
TypeDescription
void 
var nextRow = 0;
var rowsPerPage = 20;
var list = GlideList2.get(listId);
if (!list)
  return;
list.setFirstRow(nextRow);
nextRow = nextRow + rowsPerPage;

GlideList2 - setGroupBy(String groupBy)

Sets the list groupBy criteria for a single field.

NameTypeDescription
groupByStringThe groupBy criteria for the list.
TypeDescription
void 
function runContextAction(listId) {
  var g_list = GlideList2.get(listId);
  g_list.setGroupBy('');
  g_list.refresh(1);
}

GlideList2 - setOrderBy(String orderBy)

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.

NameTypeDescription
orderByStringSingle or multiple orderBy fields.
TypeDescription
void 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            updateOrderBy: function(orderBy){
  var list = GlideList2.get(this.listID);
  if (list)
    list.setOrderBy(orderBy);
};

GlideList2 - setRowsPerPage(Number rows)

Sets the number of rows per page to display.

NameTypeDescription
rowsNumberThe number of rows to display.
TypeDescription
void 
link: function(scope) {
  var list = GlideList2.get(scope.listId);
  list.setRowsPerPage(scope.maxRows);
  list.setFilterAndRefresh(scope.tableQuery);
}

GlideList2 - showHideGroups(Boolean showFlag)

Shows or hides all the groups within the list and saves the current collapsed/expanded state of the groups as a user preference.

NameTypeDescription
showFlagBooleanIf true, shows the groups within the list.
TypeDescription
void 
function showHideAllGroups(showFlag) {
  var list = GlideList2.get(listId);
  if (!list)
    return;
  list.showHideGroups(showFlag);
}

GlideList2 - showHideList(Boolean showFlag)

Displays or hides the list and saves the current collapsed/expanded state of the list as a user preference.

NameTypeDescription
showFlagBooleanIf true, displays the list.
TypeDescription
void 
GlideList2.toggleAll = function(expandFlag) {
for (var id in GlideLists2) {
  var list = GlideLists2[id];
list.showHideList(expandFlag);
}

GlideList2 - sort(String field)

Sorts the list in ascending order and sets the field as an orderBy column.

NameTypeDescription
fieldStringField to use to sort the list.
TypeDescription
void 
$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)

Sorts a single field in the list in descending order and sets the field as an orderByDescField column.

NameTypeDescription
fieldStringField to use to sort the list.
TypeDescription
void 
$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()

Toggles the display of the list and saves the current collapsed/expanded state of the list as a user preference.

NameTypeDescription
none  
TypeDescription
void 
var list = GlideList2.get(listId);
if (!list)
  return;
list.toggleList();

GlideList2 - toggleListNoPref()

Toggles the display of the list but does not save the current collapsed/expanded state of the list as a user preference.

NameTypeDescription
none  
TypeDescription
void 
var list = GlideList2.get(listId);
if (!list)
  return;
list.toggleListNoPref();