---
sourceDocument: Australia API Reference
sourceDocumentLink: https://www.servicenow.com/docs/r/api-reference

 Release :

    - australia

ft:locale :

    - en-US

ft:publication_title :

    - Australia API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# GlideRecord - Client

# GlideRecord - Client {#ariaid-title1}

* Release version: Australia
* 
* Updated March 12, 2026
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 8 minutes to read

The GlideRecord API provides methods that perform database operations. This API enables the use of some GlideRecord functionality in client-side scripts, such as client scripts and UI policy
scripts.

A GlideRecord contains both records and fields. Queries made with client-side GlideRecord methods are executed on the server. Therefore, a request is made from the client browser to obtain the record data.

The client-side GlideRecord API is not supported in scoped applications. Instead, create a script include and use the [GlideAJAX](https://www.servicenow.com/docs/b76T3jo05vs3S9T_imUWsA#c_GlideAjaxAPI "The GlideAjax class enables a client script to call server-side code in a script include.") API, or use the REST APIs. In addition, this API applies access control lists (ACLs) based on the credentials of the user executing the script. To execute the code on
the server without ACLs, use the [GlideAjax](https://www.servicenow.com/docs/b76T3jo05vs3S9T_imUWsA#c_GlideAjaxAPI "The GlideAjax class enables a client script to call server-side code in a script include.") API.

## Client side GlideRecord - GlideRecord(String
tableName) {#ariaid-title2}

Creates an instance of the GlideRecord class for the specified table.
{#r_GRCS-GlideRecord_S__table_c1c_25j_3v__entry__3}

| Name | Type | Description |
|-|-|-|
| tableName | String | The table to be used. |
[Table 1. Parameters]

{#r_GRCS-GlideRecord_S__table_c1c_25j_3v}  

    var now_GR = new GlideRecord('incident');

## Client side GlideRecord - addOrderBy(String
column) {#ariaid-title3}

Adds a column to order by in the query.
{#r_GRCS-addOrderBy_S__table_zrw_wjw_hv__entry__3}

| Name | Type | Description |
|-|-|-|
| column | String | The column by which to order the result set. |
[Table 2. Parameters]

{#r_GRCS-addOrderBy_S__table_zrw_wjw_hv} {#r_GRCS-addOrderBy_S__table_asw_wjw_hv__entry__2}

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

{#r_GRCS-addOrderBy_S__table_asw_wjw_hv}

## Client side GlideRecord - addQuery(String name, Object
value) {#ariaid-title4}

Adds a query to return records where the specified field name is equal to a specified
value (or is in a list of values).
If you are familiar with SQL, this method is similar to the "where" clause. You can create
one or more queries for a single filter by calling this method multiple times; for this
method the queries are AND'ed. Once you define all of the desired queries, call the [Client side GlideRecord - query(String name, Function responseFunction, String value)](https://www.servicenow.com/docs/w14yhrb5HwEDP8eoWINg6w#r_GRCS-query_Function "Runs the query to the server against the table based on the addQuery() filter. This method queries the GlideRecord table as well as any references of the table.") to execute the specified query clause (filter).

To perform an operation other than AND, use either the [addQuery(String name, Object operator, Object
value)](https://www.servicenow.com/docs/w14yhrb5HwEDP8eoWINg6w#r_GRCS-addQuery_S_O_O "Adds a filter to return records where the field meets the specified condition (field, operator, value).") method or the [setEncodedQuery()](https://www.servicenow.com/docs/w14yhrb5HwEDP8eoWINg6w#r_GRCS-setEncodedQuery "Adds a specified encoded query string to the current query clause.") method.
{#r_GRCS-addQuery_S_O__table_rhl_n4v_hv__entry__3}

| Name | Type | Description |
|-|-|-|
| name | String | Name of the field to check. |
| value | Object | The value or list of values on which to query. |
[Table 4. Parameters]

{#r_GRCS-addQuery_S_O__table_rhl_n4v_hv} {#r_GRCS-addQuery_S_O__table_shl_n4v_hv__entry__2}

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

{#r_GRCS-addQuery_S_O__table_shl_n4v_hv}  
Example showing multiple queries.

    var now_GR = new GlideRecord('incident');
    now_GR.addQuery('priority', 4); // Priority is 4 -- Low and,
    now_GR.addQuery('state', 3); // State is On Hold
    now_GR.query(response);
     
    function response(result) {
        while(result.next()) {
           // Print all INC with priority 4 -- Low AND state is On Hold
            console.log(result.getValue('number')); 
        }
    }

Example showing how to pass a string object.

    var now_GR = new GlideRecord('incident');
    now_GR.addQuery('short_description', new String('USB device not working')); // string object
    now_GR.addQuery('priority', 4); //number
    now_GR.query(response);
     
    function response(result) {
        while(result.next()) {
           // Print all INC with priority 4 -- Low AND short description contains 'USB device not working'
            console.log(result.getValue('number')); 
        }
    }

## Client side GlideRecord - addQuery(String name, Object
operator, Object value) {#ariaid-title5}

Adds a filter to return records where the field meets the specified condition (field,
operator, value).
If you are familiar with SQL, this method is similar to the "where" clause. You can create
one or more queries for a single filter by calling this method multiple times. Once you
define all of the desired queries, call the [Client side GlideRecord - query(String name, Function responseFunction, String value)](https://www.servicenow.com/docs/w14yhrb5HwEDP8eoWINg6w#r_GRCS-query_Function "Runs the query to the server against the table based on the addQuery() filter. This method queries the GlideRecord table as well as any references of the table.") to
execute the specified query clause (filter).

To create more complex queries, use the [setEncodedQuery()](https://www.servicenow.com/docs/w14yhrb5HwEDP8eoWINg6w#r_GRCS-setEncodedQuery "Adds a specified encoded query string to the current query clause.") method.
{#r_GRCS-addQuery_S_O_O__table_wgh_cpv_hv__entry__3}

| Name | Type | Description |
|-|-|-|
| name | String | Name of the field to check. |
| operator | Object | Query operator. The available values are dependent on the data type of the <var class="keyword varname">value</var> parameter. Numbers: * = * != * \> * \>= * \< * \<= {#r_GRCS-addQuery_S_O_O__ul_qyb_rbt_3y} Strings (must be in upper case): * = * != * IN * NOT IN * STARTSWITH * ENDSWITH * CONTAINS * DOES NOT CONTAIN * INSTANCEOF {#r_GRCS-addQuery_S_O_O__ul_egz_vbt_3y} Note: Don't use the LIKE operator. Use CONTAINS instead. |
| value | Object | Value on which to query (not case-sensitive). |
[Table 6. Parameters]

{#r_GRCS-addQuery_S_O_O__table_wgh_cpv_hv} {#r_GRCS-addQuery_S_O_O__table_xgh_cpv_hv__entry__2}

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

{#r_GRCS-addQuery_S_O_O__table_xgh_cpv_hv}  
Example showing how to add multiple queries to a filter.

    var now_GR = new GlideRecord('incident');
    now_GR.addQuery('priority', '<=', 2); // Priority is 2 or higher and,
    now_GR.addQuery('short_description', 'CONTAINS', 'crash'); // Short description contains the word crash
    now_GR.query(response);
     
    function response(result) {
        while(result.next()) {
           // Print all INC with priority of 2 or higher AND short description contains "crash"
            console.log(result.getValue('number')); 
        }
    }

Example showing how to pass in an array to verify multiple conditions in a single
query.

    var priorities = [4,2]; 
    var now_GR = new GlideRecord('incident'); 
    now_GR.addQuery('priority', 'IN', priorities); 
    now_GR.query(response); 

    function response(result) {
      while(result.next()) {
        console.log(result.getValue('number')); 
      } 
    }

## Client side GlideRecord - deleteRecord(Function
responseFunction) {#ariaid-title6}

Deletes the current record and calls the specified response function when
complete.
{#r_GRCS-deleteRecord_Function__table_esv_hqv_hv__entry__3}

| Name | Type | Description |
|-|-|-|
| responseFunction | Function | Response function for the callback. |
[Table 8. Parameters]

{#r_GRCS-deleteRecord_Function__table_esv_hqv_hv} {#r_GRCS-deleteRecord_Function__table_fsv_hqv_hv__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 9. Returns]

{#r_GRCS-deleteRecord_Function__table_fsv_hqv_hv}  
This example deletes a record and then calls the response function
<var class="keyword varname">response</var> to log an alert message.

    var recordGR = new GlideRecord('incident');
    if (recordGR.get('99ebb4156fa831005be8883e6b3ee4b9')) {
      recordGR.deleteRecord(response);
    }

    function response(result) {
      alert('Deleted record sys_id: ' + result.getValue('sys_id'));
    }

Output:

    Deleted record sys_id: 99ebb4156fa831005be8883e6b3ee4b9

## Client side GlideRecord - get(String sys_id) {#ariaid-title7}

Executes a GlideRecord query for a record with the specified sys_id. This method is
expected to be used to query for single records, so a next operation is performed before
returning.
{#r_GRCS-get_O__table_u3j_fhw_hv__entry__3}

| Name | Type | Description |
|-|-|-|
| sys_id | String | The sys_id of the record to be found. |
[Table 10. Parameters]

{#r_GRCS-get_O__table_u3j_fhw_hv} {#r_GRCS-get_O__table_v3j_fhw_hv__entry__2}

| Type | Description |
|-|-|
| Boolean | True if one or more matching records was found. False if no records were found. |
[Table 11. Returns]

{#r_GRCS-get_O__table_v3j_fhw_hv}

## Client side GlideRecord - getEncodedQuery() {#ariaid-title8}

Retrieves the query condition of the current result set as an encoded query
string.
{#r_GRCS-getEncodedQuery__table_wfk_spv_hv__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 12. Parameters]

{#r_GRCS-getEncodedQuery__table_wfk_spv_hv} {#r_GRCS-getEncodedQuery__table_xfk_spv_hv__entry__2}

| Type | Description |
|-|-|
| String | An encoded query string containing all conditions that have been added to the query. |
[Table 13. Returns]

{#r_GRCS-getEncodedQuery__table_xfk_spv_hv}

## Client side GlideRecord - getLimit() {#ariaid-title9}

Returns the limit for records to be returned by the GlideRecord query.
{#r_GRCS-getLimit__table_pll_qlw_hv__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 14. Parameters]

{#r_GRCS-getLimit__table_pll_qlw_hv} {#r_GRCS-getLimit__table_qll_qlw_hv__entry__2}

| Type | Description |
|-|-|
| Number | The limit for records to be returned by the GlideRecord query. |
[Table 15. Returns]

{#r_GRCS-getLimit__table_qll_qlw_hv}

## Client side GlideRecord - getTableName() {#ariaid-title10}

Retrieves the name of the table associated with this GlideRecord.
{#r_GRCS-getTableName__table_art_5hw_hv__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 16. Parameters]

{#r_GRCS-getTableName__table_art_5hw_hv} {#r_GRCS-getTableName__table_brt_5hw_hv__entry__2}

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

{#r_GRCS-getTableName__table_brt_5hw_hv}  

    var item = new GlideRecord('sc_request'); 
    item.addQuery('sys_id', current.request); 
    item.query(itemResponse); 
     
    function itemResponse(item) {
       alert('The table is ' + item.getTableName());
    }

## Client side GlideRecord - hasNext() {#ariaid-title11}

Determines if there are any more records in the GlideRecord.
{#r_GRCS-hasNext__table_ejm_m3w_hv__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 18. Parameters]

{#r_GRCS-hasNext__table_ejm_m3w_hv} {#r_GRCS-hasNext__table_fjm_m3w_hv__entry__2}

| Type | Description |
|-|-|
| Boolean | True if there are more records in the query set. |
[Table 19. Returns]

{#r_GRCS-hasNext__table_fjm_m3w_hv}

## Client side GlideRecord - insert(Function
responseFunction) {#ariaid-title12}

Inserts a new record using the field values that have been set for the current
record.
{#r_GRCS-insert_Function__table_szb_x3w_hv__entry__3}

| Name | Type | Description |
|-|-|-|
| responseFunction | Function | Function to execute once the record is inserted. |
[Table 20. Parameters]

{#r_GRCS-insert_Function__table_szb_x3w_hv} {#r_GRCS-insert_Function__table_tzb_x3w_hv__entry__2}

| Type | Description |
|-|-|
| String | Sys_id of the inserted record, or null if the record was not inserted. |
[Table 21. Returns]

{#r_GRCS-insert_Function__table_tzb_x3w_hv}  

    var now_GR = new GlideRecord('incident');
    now_GR.short_description = 'Learn about GlideRecord';
    var recResponse = now_GR.insert(handleResponse);

    function handleResponse(recResponse, answer) {
    // Answer will be the sys_id of the created record or null
    alert('Newly created sys_id is - ' + answer + ' exists');
    }

## Client side GlideRecord - next() {#ariaid-title13}

Moves to the next record in the GlideRecord.
{#r_GRCS-next__table_ldp_jjw_hv__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 22. Parameters]

{#r_GRCS-next__table_ldp_jjw_hv} {#r_GRCS-next__table_mdp_jjw_hv__entry__2}

| Type | Description |
|-|-|
| Boolean | False if there are no more records in the query set. |
[Table 23. Returns]

{#r_GRCS-next__table_mdp_jjw_hv}  

    var rec = new GlideRecord('incident');
    rec.query(recResponse);
     
    function recResponse(rec) {
      while (rec.next()) { 
        alert(rec.number + ' exists');
      }
    }

## Client side GlideRecord - orderBy(String column) {#ariaid-title14}

Specifies an orderBy column. May be called more than once to order by multiple
columns.
{#r_GRCS-orderBy_S__table_jhj_3kw_hv__entry__3}

| Name | Type | Description |
|-|-|-|
| column | String | The column name to be used to order the result set. |
[Table 24. Parameters]

{#r_GRCS-orderBy_S__table_jhj_3kw_hv} {#r_GRCS-orderBy_S__table_khj_3kw_hv__entry__2}

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

{#r_GRCS-orderBy_S__table_khj_3kw_hv}  

    function UpdateProjectWBS(project) {
      var count = 0;
      var child = new GlideRecord('pm_project_task');
      child.addQuery('parent', project.sys_id);
      child.orderBy('order');
      child.orderBy('number');
      child.query(childResponse);
      g_form.addInfoMessage(count + ' Project Tasks updated');
    }
     
    function childResponse(child) {
      var len = child.getRowCount().toString().length;
      var seq = 0;
      while (child.next()) {
        count += UpdateProjectTaskWBS(child, 1, ++seq, len, '');
      }
    }

## Client side GlideRecord - query(String name, Function
responseFunction, String value) {#ariaid-title15}

Runs the query to the server against the table based on the addQuery() filter. This
method queries the GlideRecord table as well as any references of the table.
Do not make synchronous query calls. Performing a query without a response function makes
the call synchronous, which means that the display will wait for the query response before
continuing.
{#r_GRCS-query_Function__table_zbp_qjl_3v__entry__3}

| Name | Type | Description |
|-|-|-|
| name | String | Optional. The name of a field to query. |
| responseFunction | Function | The function called when the query results are available. |
| value | String | Optional. The field value to query for. Any pair of literals is considered a query pair (field : value). |
[Table 26. Parameters]

{#r_GRCS-query_Function__table_zbp_qjl_3v} {#r_GRCS-query_Function__table_dg5_wkw_hv__entry__2}

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

{#r_GRCS-query_Function__table_dg5_wkw_hv}  
The following is a basic example with a response function.

    var rec = new GlideRecord('incident');
    rec.query(recResponse);
     
    function recResponse(rec) {
      while (rec.next()) { 
       alert(rec.number + ' exists');
      } 
    }

The following example shows the difference between synchronus and asynchronous syntax, with
an asynchronous example.

    // synchronous call syntax (no response function): DO NOT USE
            query();
            
            // asynchronous call syntax
            // performs query with current conditions, calls responseFunction when done
            query(responseFunction)
            
            // synchronous call syntax (no response function): DO NOT USE
            // adds "category=hardware" to current query conditions and performs query
            query('category', 'hardware')
            
            // asynchronous call syntax
            // adds "category=hardware" to current query conditions, performs query, and calls responseFunction when done
            query('category', 'hardware', responseFunction)
            
            // asynchronous call example
            // adds "user_name=abel.tuter" to current query conditions, performs query, and calls defined response function when done
            function onLoad() {
            var now_GR = new GlideRecord("sys_user");
            now_GR.query("user_name", "abel.tuter", function(now_GR) {
            if (now_GR.next()) {
            alert("You can access fields by name from the client API, just like in the server API:\n now_GR.name = " + now_GR.name);
            alert("You can also access fields using getValue():\n now_GR.getValue(\"email\") = " + now_GR.getValue("email"));
            if (now_GR.getDisplayValue) {
            alert("In Service Portal, Mobile, and Agent Workspace, you can access a field's display value:\n now_GR.getDisplayValue(\"company\") = " + now_GR.getDisplayValue("company"));
            } else {
            alert("On the desktop, you cannot access a field's display value, but can get its sys_id:\n now_GR.company = " + now_GR.company);
            }
            alert("You cannot dot-walk in the client API:\n now_GR.company.name = " + now_GR.company.name);
            }
            });
            }

## Client side GlideRecord - setEncodedQuery(String
encodedQuery) {#ariaid-title16}

Adds a specified encoded query string to the current query clause.
This method enables you to specify complex filters (encoded query strings) in a single
query call, unlike other client-side addQuery() methods. Once you define
all of the desired queries, call the [Client side GlideRecord - query(String name, Function responseFunction, String value)](https://www.servicenow.com/docs/w14yhrb5HwEDP8eoWINg6w#r_GRCS-query_Function "Runs the query to the server against the table based on the addQuery() filter. This method queries the GlideRecord table as well as any references of the table.") to execute
the specified query clause (filter). For additional information on encoded query strings,
refer to [Encoded query strings](https://www.servicenow.com/docs/access?context=c_EncodedQueryStrings&version=australia&pubname=australia-platform-user-interface&ft:locale=en-US).

If you call this method multiple times before calling the query() method, the queries are
AND'ed together.
{#r_GRCS-setEncodedQuery__table_bpl_gvw_zgb__entry__3}

| Name | Type | Description |
|-|-|-|
| encodedQuery | String | Encoded query string to add to the current query clause. |
[Table 28. Parameters]

{#r_GRCS-setEncodedQuery__table_bpl_gvw_zgb} {#r_GRCS-setEncodedQuery__table_cpl_gvw_zgb__entry__2}

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

{#r_GRCS-setEncodedQuery__table_cpl_gvw_zgb}  

    var now_GR = new GlideRecord('incident');
    now_GR.setEncodedQuery('priority=4^ORstate=3');
    now_GR.query(response);
     
    function response(result) {
        while(result.next()) {
            console.log(result.getValue('number'));
        }
    }

## Client side GlideRecord - setLimit(Number
maxQuery) {#ariaid-title17}

Sets the limit for how many records are in the GlideRecord.
{#r_GRCS-setLimit_N__table_c4d_3lw_hv__entry__3}

| Name | Type | Description |
|-|-|-|
| maxQuery | Number | The limit for the number of records to retrieve. |
[Table 30. Parameters]

{#r_GRCS-setLimit_N__table_c4d_3lw_hv} {#r_GRCS-setLimit_N__table_d4d_3lw_hv__entry__2}

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

{#r_GRCS-setLimit_N__table_d4d_3lw_hv}

