Please use docs.servicenow.com for the latest documentation.

This site is for reference purposes only and may not be accurate for the latest ServiceNow version

GlideList2 (g list)

From Wiki Archive
Jump to: navigation, search
Note
Note: This article applies to Fuji. For more current information, see Glide Class Overview at http://docs.servicenow.com

The ServiceNow Wiki is no longer being updated. Please refer to http://docs.servicenow.com for the latest product documentation.

Overview

GlideList2.js is a JavaScript class used to customize (v2) lists.

g_list is the variable 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.

Where To Use

These methods are used in UI Context Menus and in UI Actions.

Filter Methods

Change or return the filter information for the list.

Method Summary
Return Value Details
queryCondition addFilter(String filter)
Adds a single term to the list query filter.
queryString getFixedQuery()
Returns the sysparm_fixed query.
queryString getQuery([boolean orderBy], [boolean groupBy], [boolean fixed], [boolean all])
Returns the encoded query string for the list.
void setFilter(String filter)
Sets the encoded query string for the list, ignoring the orderBy and groupBy parts of the query string.
void 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.

Display Methods

Change display options or get information about how the list is displayed.

Method Summary
Return Value Details
String getGroupBy()
Returns the field or comma-separated list of fields that are used to group the list.
String getOrderBy()
Returns the first field that is used to order by or a blank.
void 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.
void refreshWithOrderBy([number FirstRow], [String additionalParms])
Refreshes the list. The orderBy part of the list filter is included if it is currently specified for the list.
void setFirstRow(number rowNum)
Sets the first row that will be displayed in the list when the list is refreshed.
void setGroupBy(String groupBy)
Sets the groupBy criteria for the list, for a single field or multiple fields.
void setOrderBy(String orderBy)
Sets the orderBy criteria for the list.
void setRowsPerPage(number rows)
Sets the number of rows per page to display.
void showHideGroups(boolean showFlag)
Displays or hides all of the groups within the list and saves the current collapsed/expanded state of the groups as a user preference.
void showHideList(boolean showFlag)
Displays or hides the list and saves the current collapsed/expanded state of the list as a user preference.
void sort(String field)
Sorts the list in ascending order and saves the choice.
void sortDescending(String field)
Sorts the list in descending order and saves the choice.
void toggleList()
Toggles the display of the list and saves the current collapsed/expanded state of the list as a user preference.
void toggleListNoPref()
Toggles the display of the list without setting any user preference.

Information Methods

Get information about the list, attributes of the list, or some items in the list.

Method Summary
Return Value Details
object get(String listID or DOMElement element)
Returns the GlideList2 object for the list or for the list that contains the specified item.
sysIdList getChecked()
Returns a comma-separated list of the sys_ids for the items that are checked in the list.
String getListName()
Returns the name of the list, which is usually the table name.
String getParentTable()
Returns the name of the parent table (the table associated with the form).
String getRelated()
Returns the related list field that associates the related list to the parent form.
String getTableName()
Returns the table name for the list.
String getTitle()
Returns the list title.
String getView()
Returns the view used to display the list.
boolean isUserList()
Returns true if the list has been personalized by the user by choosing the list mechanic and changing the list layout.


[top of page]

Method Detail

addFilter

queryCondition addFilter(String filter)

Adds a single term to the list query filter.
Parameters:
String filter - query string condition.
Returns:
queryCondition - adds a single term to the filter (such as a field operator value).
Example:
<source lang="javascript">

g_list.addfilter("active=true"); </source>


get

object get(String listID or DOMElement element)

Returns the GlideList2 object for the list or for the list that contains the specified item.
Parameters:
String listID or DOMElement element - specifies the list by list ID or specifies the list by element.
Returns:
object - the GlideList2 object or null if not found.



getChecked

sysIdList getChecked()

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



getFixedQuery

queryString getFixedQuery()

Returns the sysparm_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. See Fixed Queries in Breadcrumbs for more information.
Returns:
queryString - the fixed query string for the list.





getGroupBy

String getGroupBy()

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



getListName

String getListName()

Returns the name of the list, which is usually the table name.
Returns:
String - the list name (usually the table name).



getOrderBy

String getOrderBy()

Returns the first field that is used to order by or a blank.
Returns:
String - field used for order or blank.



getParentTable

String getParentTable()

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





getQuery

queryString getQuery([boolean orderBy], [boolean groupBy], [boolean fixed], [boolean all])

Returns the encoded query string for the list.
Optional: include orderBy, groupBy, fixed query or all of them.
Parameters:
boolean orderBy (optional) - true includes the orderBy in the encoded query string.
boolean groupBy (optional) - true includes the groupBy in the encoded query string.
boolean fixed (optional) - true includes fixed query in the encoded query string.
boolean all (optional) - true includes orderBy, groupBy and fixed query.
Returns:
queryString - encoded query string for the list.




getRelated

String getRelated()

Returns the related list field that associates the related list to the parent form.
Returns:
String - field that connects the list to the parent form.

getTableName

String getTableName()

Returns the table name for the list.
Returns:
String - table name.



getTitle

String getTitle()

Returns the list title.
Returns:
String - list title.



getView

String getView()

Returns the view used to display the list.
Returns:
String - name of the view.




isUserList

boolean isUserList()

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



refresh

void 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.
Optional - Specify the first row to show in the list. If not specified, the current list's first row is used. See setFirstRow.
Optional - Name=value pairs that are submitted as URI query parameters with the list refresh request to the server.
Parameters:
number firstRow (optional) - the first row to display in the list.
String additionalParms (optional) - name=value pairs that are submitted with the list refresh request.
Returns:
void



refreshWithOrderBy

void refreshWithOrderBy([number firstRow], [String additionalParms])

Refreshes the list. The orderBy part of the list filter is included if it is currently specified for the list.
Parameters:
number firstRow (optional) - the first row to display in the list.
String additionalParms (optional) - name=value pairs that are submitted with the list refresh request.
Returns:
void



setFilter

void setFilter(String filter)

Sets the encoded query string for the list, ignoring the orderBy and groupBy parts of the query string.
Parameters:
String filter - encoded query string.
Returns:
void




setFilterAndRefresh

void 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.
Parameters:
String filter - encoded query string.
Returns:
void



setFirstRow

void setFirstRow(number rowNum)

Sets the first row that will be displayed in the list when the list is refreshed.
Parameters:
number rowNum - row number of the first row to be displayed.
Returns:
void



setGroupBy

void setGroupBy(String groupBy)

Sets the groupBy criteria for the list, for a single field or multiple fields.
For a single field, use field or groupByField. The groupBy prefix is optional.
For multiple fields use field1^field2^field3 or groupByField1^groupByField2^groupByField3.
Parameters:
String groupBy - groupBy criteria for the list, one field or multiple fields.
Returns:
void




setOrderBy

void setOrderBy(String orderBy)

Sets the orderBy criteria for the list.
For a single order by field use orderBy field or orderByDescField.
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 assumed.
Parameters:
String orderBy - single or multiple order by fields.
Returns:
void



setRowsPerPage

void setRowsPerPage(number rows)

Sets the number of rows per page to display.
Parameters:
number rows - specifies the number of rows to display per page.
Returns:
void



showHideGroups

void showHideGroups(boolean showFlag)

Displays or hides all of the groups within the list and saves the current collapsed/expanded state of the groups as a user preference.
Parameters:
boolean showFlag - true displays the groups within the list.
Returns:
void



showHideList

void showHideList(boolean showFlag)

Displays or hides the list and saves the current collapsed/expanded state of the list as a user preference.
Parameters:
boolean showFlag - true displays the list.
Returns:
void



sort

void sort(String field)

Sorts the list in ascending order and saves the choice.
Parameters:
String field - specifies the field used to sort the list.
Returns:
void



sortDescending

void sortDescending(String field)

Sorts the list in descending order and saves the choice.
Parameters:
String field - specifies the field used to sort the list.
Returns:
void






toggleList

void toggleList()

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



toggleListNoPref

void toggleListNoPref()

Clears the image for an item.
Parameters:
GlideMenu item - Toggles the display of the list without setting any user preference.
Returns:
void




[top of page]