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


---

# GlideSystem - Scoped

# GlideSystem - Scoped {#ariaid-title1}

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

The scoped GlideSystem API provides a number of convenient methods to obtain information about the system, the current logged in user, and other system level information.

Many of the GlideSystem methods facilitate the easy inclusion of dates in query ranges, and are most often used in filters and reporting.

## Scoped GlideSystem - addErrorMessage(String message) {#ariaid-title2}

Adds an error message for the current session.
{#r_ScopedGlideSystemAddErrorMessage_Object__table_agh_2sm_1r__entry__3}

| Name | Type | Description |
|-|-|-|
| message | String | Message to add. |
[Table 1. Parameters]

{#r_ScopedGlideSystemAddErrorMessage_Object__table_agh_2sm_1r} {#r_ScopedGlideSystemAddErrorMessage_Object__table_tvy_nhr_2r__entry__2}

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

{#r_ScopedGlideSystemAddErrorMessage_Object__table_tvy_nhr_2r}  

    gs.include("PrototypeServer");
      var ValidatePasswordStronger = Class.create();
      ValidatePasswordStronger.prototype = {
           process : function() {
              var user_password = request.getParameter("user_password");
              var min_len = 8;
              var rules = "Password must be at least " + min_len + 
                 " characters long and contain a digit, an uppercase letter, and a lowercase letter.";
              if (user_password.length() < min_len) {
                 gs.addErrorMessage("TOO SHORT: " + rules);
                 return false;
              }
              var digit_pattern = new RegExp("[0-9]", "g");
              if (!digit_pattern.test(user_password)) {
                 gs.addErrorMessage("DIGIT MISSING: " + rules);
                 return false;
              }
              var upper_pattern = new RegExp("[A-Z]", "g");
              if (!upper_pattern.test(user_password)) {
                 gs.addErrorMessage("UPPERCASE MISSING: " + rules);
                 return false;
              }
              var lower_pattern = new RegExp("[a-z]", "g");
              if (!lower_pattern.test(user_password)) {
                 gs.addErrorMessage("LOWERCASE MISSING: " + rules);
                 return false;
              }
              return true; // password is OK
           }
      }

## Scoped GlideSystem - addHighMessage(String message) {#ariaid-title3}

Displays a high priority message at the top of the form.
{#SGSYS-addHighMessage_S__id_bzs_nft_pfc__entry__3}

| Name | Type | Description |
|-|-|-|
| message | String | High priority message to display. |
[Table 3. Parameters]

{#SGSYS-addHighMessage_S__id_bzs_nft_pfc__entry__8}

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

The following example shows how to display a high priority message at the top of the form.

    gs.addHighMessage("This is a high priority message");

## Scoped GlideSystem - addInfoMessage(String message) {#ariaid-title4}

Adds an info message for the current session. This method is not supported for
asynchronous business rules.
{#r_ScopedGlideSystemAddInfoMessage_Object__table_twj_rsm_1r__entry__3}

| Name | Type | Description |
|-|-|-|
| message | String | Info message to add. |
[Table 5. Parameters]

{#r_ScopedGlideSystemAddInfoMessage_Object__table_twj_rsm_1r} {#r_ScopedGlideSystemAddInfoMessage_Object__table_ytc_4hr_2r__entry__2}

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

{#r_ScopedGlideSystemAddInfoMessage_Object__table_ytc_4hr_2r}  

    if ((!current.u_date1.nil()) && (!current.u_date2.nil())) {
      var start = current.u_date1.getGlideObject().getNumericValue();
      var end = current.u_date2.getGlideObject().getNumericValue();
      if (start > end) {
        gs.addInfoMessage('start must be before end');
        current.u_date1.setError('start must be before end');
        current.setAbortAction(true);
      }
    }

## Scoped GlideSystem - addLowMessage(String message) {#ariaid-title5}

Displays a low priority message at the top of the form.
{#SGSYS-addLowMessage_S__id_ucr_2ft_pfc__entry__3}

| Name | Type | Description |
|-|-|-|
| message | String | Low priority message to display. |
[Table 7. Parameters]

{#SGSYS-addLowMessage_S__id_ucr_2ft_pfc__entry__8}

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

The following example shows how to display a low priority message at the top of the form.

    gs.addLowMessage("This is a low priority message");

## Scoped GlideSystem - addModerateMessage(String message) {#ariaid-title6}

Displays a moderate priority message at the top of the form.
{#SGSYS-addModerateMessage_S__id_ykw_52t_pfc__entry__3}

| Name | Type | Description |
|-|-|-|
| message | String | Moderate message to display. |
[Table 9. Parameters]

{#SGSYS-addModerateMessage_S__id_ykw_52t_pfc__entry__8}

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

The following example shows how to display a moderate priority message at the top of the form.

    gs.addModerateMessage("This is a moderate priority message");

## Scoped GlideSystem - addSuccessMessage (String message) {#ariaid-title7}

Displays a message confirming a successful action at the top of the form.
{#SGSYS-addSuccessMessage_S__id_jzn_n2t_pfc__entry__3}

| Name | Type | Description |
|-|-|-|
| message | String | Success message to display. |
[Table 11. Parameters]

{#SGSYS-addSuccessMessage_S__id_jzn_n2t_pfc__entry__8}

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

The following example shows how to display a message confirming a success message at the top of the form.

    gs.addSuccessMessage("This is a success message");

## Scoped GlideSystem - base64Encode(String source) {#ariaid-title8}

Creates a base64 string from the specified string.
{#r_SGSYS-base64Encode_S__table_brj_hhk_bx__entry__3}

| Name | Type | Description |
|-|-|-|
| source | String | String to encode. |
[Table 13. Parameters]

{#r_SGSYS-base64Encode_S__table_brj_hhk_bx} {#r_SGSYS-base64Encode_S__table_crj_hhk_bx__entry__2}

| Type | Description |
|-|-|
| String | Encoded base64 string. |
[Table 14. Returns]

{#r_SGSYS-base64Encode_S__table_crj_hhk_bx}  
The following code example shows how to call this method.

    var mac = new CertificateEncryption;
    var key = "sample_key"; 
    key = gs.base64Encode(key);
    mac.generateMac(key, "HmacSHA256", "sample_data");

## Scoped GlideSystem - base64Decode(String source) {#ariaid-title9}

Returns an ASCII string from the specified base64 string.
{#r_SGSYS-base64Decode_S__table_tsg_ngk_bx__entry__3}

| Name | Type | Description |
|-|-|-|
| source | String | A base64 encoded string. |
[Table 15. Parameters]

{#r_SGSYS-base64Decode_S__table_tsg_ngk_bx} {#r_SGSYS-base64Decode_S__table_usg_ngk_bx__entry__2}

| Type | Description |
|-|-|
| String | The decoded string. |
[Table 16. Returns]

{#r_SGSYS-base64Decode_S__table_usg_ngk_bx}

## Scoped GlideSystem - beginningOfLastMonth() {#ariaid-title10}

Returns the date and time for the beginning of last month in the user's session time zone as a UTC timestamp.
{#SGSYS-beginningOfLastMonth__table_fdv_b1r_fz__entry__3}

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

{#SGSYS-beginningOfLastMonth__table_fdv_b1r_fz} {#SGSYS-beginningOfLastMonth__table_gdv_b1r_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC beginning of last month, in the format yyyy-mm-dd hh:mm:ss |
[Table 18. Returns]

{#SGSYS-beginningOfLastMonth__table_gdv_b1r_fz}

## Scoped GlideSystem - beginningOfLastWeek() {#ariaid-title11}

Returns the date and time for the beginning of last week in the user's session time zone as a UTC timestamp.
{#SGSYS-beginningOfLastWeek__table_jlb_hbr_fz__entry__3}

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

{#SGSYS-beginningOfLastWeek__table_jlb_hbr_fz} {#SGSYS-beginningOfLastWeek__table_klb_hbr_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC beginning of last week, in the format yyyy-mm-dd hh:mm:ss |
[Table 20. Returns]

{#SGSYS-beginningOfLastWeek__table_klb_hbr_fz}

## Scoped GlideSystem - beginningOfNextMonth() {#ariaid-title12}

Returns the date and time for the beginning of next month in the user's session time zone as a UTC timestamp.
{#SGSYS-beginningOfNextMonth__table_gqn_ccr_fz__entry__3}

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

{#SGSYS-beginningOfNextMonth__table_gqn_ccr_fz} {#SGSYS-beginningOfNextMonth__table_hqn_ccr_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC beginning of next month, in the format yyyy-mm-dd hh:mm:ss |
[Table 22. Returns]

{#SGSYS-beginningOfNextMonth__table_hqn_ccr_fz}

## Scoped GlideSystem - beginningOfNextWeek() {#ariaid-title13}

Returns the date and time for the beginning of next week in the user's session time zone as a UTC timestamp.
{#r_ScopedGlideSystemBeginNxtWk__table_h2f_v5v_mt__entry__3}

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

{#r_ScopedGlideSystemBeginNxtWk__table_h2f_v5v_mt} {#r_ScopedGlideSystemBeginNxtWk__table_i2f_v5v_mt__entry__2}

| Type | Description |
|-|-|
| String | The UTC beginning of next week, in the format yyyy-mm-dd hh:mm:ss. |
[Table 24. Returns]

{#r_ScopedGlideSystemBeginNxtWk__table_i2f_v5v_mt}

## Scoped GlideSystem - beginningOfNextYear() {#ariaid-title14}

Returns the date and time for the beginning of next year in the user's session time zone as a UTC timestamp.
{#SGSYS-beginningOfNextYear__table_r4y_1dr_fz__entry__3}

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

{#SGSYS-beginningOfNextYear__table_r4y_1dr_fz} {#SGSYS-beginningOfNextYear__table_s4y_1dr_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC beginning of next year, in the format yyyy-mm-dd hh:mm:ss |
[Table 26. Returns]

{#SGSYS-beginningOfNextYear__table_s4y_1dr_fz}

## Scoped GlideSystem - beginningOfThisMonth() {#ariaid-title15}

Returns the date and time for the beginning of this month in the user's session time zone as a UTC timestamp.
{#SGSYS-beginningOfThisMonth__table_g1g_wdr_fz__entry__3}

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

{#SGSYS-beginningOfThisMonth__table_g1g_wdr_fz} {#SGSYS-beginningOfThisMonth__table_h1g_wdr_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC beginning of this month, in the format yyyy-mm-dd hh:mm:ss |
[Table 28. Returns]

{#SGSYS-beginningOfThisMonth__table_h1g_wdr_fz}

## Scoped GlideSystem - beginningOfThisQuarter() {#ariaid-title16}

Returns the date and time for the beginning of this quarter in the user's session time zone as a UTC timestamp.
{#SGSYS-beginningOfThisQuarter__table_jkf_xfr_fz__entry__3}

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

{#SGSYS-beginningOfThisQuarter__table_jkf_xfr_fz} {#SGSYS-beginningOfThisQuarter__table_kkf_xfr_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC beginning of this quarter, in the format yyyy-mm-dd hh:mm:ss |
[Table 30. Returns]

{#SGSYS-beginningOfThisQuarter__table_kkf_xfr_fz}

## Scoped GlideSystem - beginningOfThisWeek() {#ariaid-title17}

Returns the date and time for the beginning of this week in the user's session time zone as a UTC timestamp.
{#SGSYS-beginningOfThisWeek__table_xwc_mhr_fz__entry__3}

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

{#SGSYS-beginningOfThisWeek__table_xwc_mhr_fz} {#SGSYS-beginningOfThisWeek__table_ywc_mhr_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC beginning of this week, in the format yyyy-mm-dd hh:mm:ss |
[Table 32. Returns]

{#SGSYS-beginningOfThisWeek__table_ywc_mhr_fz}

## Scoped GlideSystem - beginningOfThisYear() {#ariaid-title18}

Returns the date and time for the beginning of this year in the user's session time zone as a UTC timestamp.
{#SGSYS-beginningOfThisYear__table_xkb_bjr_fz__entry__3}

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

{#SGSYS-beginningOfThisYear__table_xkb_bjr_fz} {#SGSYS-beginningOfThisYear__table_ykb_bjr_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC beginning of this year, in the format yyyy-mm-dd hh:mm:ss |
[Table 34. Returns]

{#SGSYS-beginningOfThisYear__table_ykb_bjr_fz}

## Scoped GlideSystem - dateGenerate(String date, String range) {#ariaid-title19}

Generates a date and time for the specified date in the user's session time zone as a UTC timestamp.
{#r_SGSYS-dateGenerate_S_S__table_mhc_ljn_zv__entry__3}

| Name | Type | Description |
|-|-|-|
| date | String | Date to generate the UTC for. Format: yyyy-mm-dd |
| range | String | Start, end, or a time in the 24 hour format hh:mm:ss. |
[Table 35. Parameters]

{#r_SGSYS-dateGenerate_S_S__table_mhc_ljn_zv} {#r_SGSYS-dateGenerate_S_S__table_nhc_ljn_zv__entry__2}

| Type | Description |
|-|-|
| String | Generated date and time. If the range is <kbd class="ph userinput">start</kbd>, the returned value is yyyy-mm-dd 00:00:00. If range is <kbd class="ph userinput">end</kbd> the return value is yyyy-mm-dd 23:59:59. Format: yyyy-mm-dd hh:mm:ss |
[Table 36. Returns]

{#r_SGSYS-dateGenerate_S_S__table_nhc_ljn_zv}  
This example shows using dateGenerate() to set the start date when
querying records in the Incident table.

    var tableData = new GlideRecord('incident');
    tableData.addEncodedQuery("sys_created_onBETWEENjavascript:gs.dateGenerate('2015-10-07','00:00:00')@javascript:gs.daysAgoEnd(0)^priority=1^severityIN1,2");
    tableData.query();
    gs.info("Count: " + tableData.getRowCount());

Output:

    Count: 7

## Scoped GlideSystem - daysAgo(Number days) {#ariaid-title20}

Returns the date and time for a specified number of days ago the user's session time zone as a UTC timestamp.
{#SGSYS-daysAgo_N__table_jtc_c4r_fz__entry__3}

| Name | Type | Description |
|-|-|-|
| days | Number | Integer number of days |
[Table 37. Parameters]

{#SGSYS-daysAgo_N__table_jtc_c4r_fz} {#SGSYS-daysAgo_N__table_ktc_c4r_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC in the format yyyy-mm-dd hh:mm:ss |
[Table 38. Returns]

{#SGSYS-daysAgo_N__table_ktc_c4r_fz}  

    function contractNoticeDue() {
        var now_GR = new GlideRecord("contract");
        now_GR.addQuery("u_contract_status", "Active");
        now_GR.query();
        while (now_GR.next()) {
        if ((now_GR.u_termination_date <= gs.daysAgo(-90)) && (now_GR.u_contract_duration == "Long")) {
                now_GR.u_contract_status = "In review";
            } 
            else if ((now_GR.u_termination_date <= gs.daysAgo(-50)) && (now_GR.u_contract_duration == "Medium")) {
            now_GR.u_contract_status = "In review";
            } 
            else if ((now_GR.u_termination_date <= gs.daysAgo(-10)) && (now_GR.u_contract_duration == "Short")) {
                now_GR.u_contract_status = "In review";
            }
        }
        now_GR.update();
    }

## Scoped GlideSystem - daysAgoEnd(Number days) {#ariaid-title21}

Returns the date and time for the end of the day a specified number of days ago. Returned in the user's session time zone as a UTC timestamp.
{#SGSYS-daysAgoEnd_N__table_bjk_dpr_fz__entry__3}

| Name | Type | Description |
|-|-|-|
| days | Number | Integer number of days |
[Table 39. Parameters]

{#SGSYS-daysAgoEnd_N__table_bjk_dpr_fz} {#SGSYS-daysAgoEnd_N__table_cjk_dpr_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC end of the day in the format yyyy-mm-dd hh:mm:ss |
[Table 40. Returns]

{#SGSYS-daysAgoEnd_N__table_cjk_dpr_fz}

## Scoped GlideSystem - daysAgoStart(Number days) {#ariaid-title22}

Returns the date and time for the beginning of the day a specified number of days ago. Returned in the user's session time zone as a UTC timestamp.
{#SGSYS-daysAgoStart_N__table_gzl_3rr_fz__entry__3}

| Name | Type | Description |
|-|-|-|
| days | String | Integer number of days |
[Table 41. Parameters]

{#SGSYS-daysAgoStart_N__table_gzl_3rr_fz} {#SGSYS-daysAgoStart_N__table_hzl_3rr_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC start of the day in the format yyyy-mm-dd hh:mm:ss |
[Table 42. Returns]

{#SGSYS-daysAgoStart_N__table_hzl_3rr_fz}  

    var now_GR = new GlideRecord('sysapproval_approver');
    now_GR.addQuery('state', 'requested');
    now_GR.addQuery('sys_updated_on', '<', gs.daysAgoStart(5));
    now_GR.query();

## Scoped GlideSystem - debug(String message, Object parm1, Object parm2, Object parm3, Object
parm4, Object parm5) {#ariaid-title23}

Writes a debug message to the system log.
{#r_ScopedGlideSystemDebug_String_Object_Object_Object_Object_Object__table_orc_4yh_1r__entry__3}

| Name | Type | Description |
|-|-|-|
| message | String | The log message with place holders for any variable arguments. |
| param1 | Object | (Optional) First variable argument. |
| param2 | Object | (Optional) Second variable argument. |
| param3 | Object | (Optional) Third variable argument. |
| param4 | Object | (Optional) Fourth variable argument. |
| param5 | Object | (Optional) Fifth variable argument. |
[Table 43. Parameters]

{#r_ScopedGlideSystemDebug_String_Object_Object_Object_Object_Object__table_orc_4yh_1r} {#r_ScopedGlideSystemDebug_String_Object_Object_Object_Object_Object__table_amy_4hr_2r__entry__2}

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

{#r_ScopedGlideSystemDebug_String_Object_Object_Object_Object_Object__table_amy_4hr_2r}  

    gs.debug("This is a debug message");
    var myFirstName = "Abel";
    var myLastName = "Tuter";
    gs.debug("This is a debug message from {0}.{1}", myFirstName, myLastName);

Output:

    This is a debug message (sys.scripts extended logging)
    This is a debug message from Abel.Tuter (sys.scripts extended logging)

## Scoped GlideSystem - endOfLastMonth() {#ariaid-title24}

Returns the date and time for the end of last month in the user's session time zone as a UTC timestamp.
{#SGSYS-endOfLastMonth__table_lch_55r_fz__entry__3}

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

{#SGSYS-endOfLastMonth__table_lch_55r_fz} {#SGSYS-endOfLastMonth__table_mch_55r_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC end of last month, in the format yyyy-mm-dd hh:mm:ss |
[Table 46. Returns]

{#SGSYS-endOfLastMonth__table_mch_55r_fz}

## Scoped GlideSystem - endOfLastWeek() {#ariaid-title25}

Returns the date and time for the end of last week in the user's session time zone as a UTC timestamp.
{#SGSYS-endOfLastWeek__table_wpm_5vr_fz__entry__3}

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

{#SGSYS-endOfLastWeek__table_wpm_5vr_fz} {#SGSYS-endOfLastWeek__table_xpm_5vr_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC end of last week, in the format yyyy-mm-dd hh:mm:ss |
[Table 48. Returns]

{#SGSYS-endOfLastWeek__table_xpm_5vr_fz}

## Scoped GlideSystem - endOfLastYear() {#ariaid-title26}

Returns the date and time for the end of last year in the user's session time zone as a UTC timestamp.
{#SGSYS-endOfLastYear__table_lmr_qwr_fz__entry__3}

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

{#SGSYS-endOfLastYear__table_lmr_qwr_fz} {#SGSYS-endOfLastYear__table_mmr_qwr_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC in format yyyy-mm-dd hh:mm:ss |
[Table 50. Returns]

{#SGSYS-endOfLastYear__table_mmr_qwr_fz}

## Scoped GlideSystem - endOfNextMonth() {#ariaid-title27}

Returns the date and time for the end of next month in the user's session time zone as a UTC timestamp.
{#SGSYS-endOfNextMonth__table_x1p_kxr_fz__entry__3}

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

{#SGSYS-endOfNextMonth__table_x1p_kxr_fz} {#SGSYS-endOfNextMonth__table_y1p_kxr_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC in the format yyyy-mm-dd hh:mm:ss |
[Table 52. Returns]

{#SGSYS-endOfNextMonth__table_y1p_kxr_fz}

## Scoped GlideSystem - endOfNextWeek() {#ariaid-title28}

Returns the date and time for the end of next week in the user's session time zone as a UTC timestamp.
{#r_ScopedGlideSystemEofNW__table_c2q_kxw_mt__entry__3}

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

{#r_ScopedGlideSystemEofNW__table_c2q_kxw_mt} {#r_ScopedGlideSystemEofNW__table_d2q_kxw_mt__entry__2}

| Type | Description |
|-|-|
| String | UTC in the format yyyy-mm-dd hh:mm:ss |
[Table 54. Returns]

{#r_ScopedGlideSystemEofNW__table_d2q_kxw_mt}

## Scoped GlideSystem - endOfNextYear() {#ariaid-title29}

Returns the date and time for the end of next year in the user's session time zone as a UTC timestamp.
{#SGSYS-endOfNextYear__table_hqq_2yr_fz__entry__3}

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

{#SGSYS-endOfNextYear__table_hqq_2yr_fz} {#SGSYS-endOfNextYear__table_iqq_2yr_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC in the format yyyy-mm-dd hh:mm:ss |
[Table 56. Returns]

{#SGSYS-endOfNextYear__table_iqq_2yr_fz}

## Scoped GlideSystem - endOfThisMonth() {#ariaid-title30}

Returns the date and time for the end of this month in the user's session time zone as a UTC timestamp.
{#SGSYS-endOfThisMonth__table_zqv_bzr_fz__entry__3}

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

{#SGSYS-endOfThisMonth__table_zqv_bzr_fz} {#SGSYS-endOfThisMonth__table_arv_bzr_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC in the format yyyy-mm-dd hh:mm:ss |
[Table 58. Returns]

{#SGSYS-endOfThisMonth__table_arv_bzr_fz}  
This example shows how to use endOfThisMonth() to set the GlideDateTime
object to the end of the current month.

    setEndDate : function(dt) {
      var gdt2 = new GlideDateTime(dt);
      gdt2.setValue(gs.endOfThisMonth());
    }

## Scoped GlideSystem - endOfThisQuarter() {#ariaid-title31}

Returns the date and time for the end of this quarter in the user's session time zone as a UTC timestamp.
{#SGSYS-endOfThisQuarter__table_ddh_p1s_fz__entry__3}

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

{#SGSYS-endOfThisQuarter__table_ddh_p1s_fz} {#SGSYS-endOfThisQuarter__table_edh_p1s_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC in the format yyyy-mm-dd hh:mm:ss |
[Table 60. Returns]

{#SGSYS-endOfThisQuarter__table_edh_p1s_fz}

## Scoped GlideSystem - endOfThisWeek() {#ariaid-title32}

Returns the date and time for the end of this week in the user's session time zone as a UTC timestamp.
{#SGSYS-endOfThisWeek__table_ggq_gbs_fz__entry__3}

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

{#SGSYS-endOfThisWeek__table_ggq_gbs_fz} {#SGSYS-endOfThisWeek__table_hgq_gbs_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC in the format yyyy-mm-dd hh:mm:ss |
[Table 62. Returns]

{#SGSYS-endOfThisWeek__table_hgq_gbs_fz}

## Scoped GlideSystem - endOfThisYear() {#ariaid-title33}

Returns the date and time for the end of this year in the user's session time zone as a UTC timestamp.
{#SGSYS-endOfThisYear__table_vqv_wbs_fz__entry__3}

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

{#SGSYS-endOfThisYear__table_vqv_wbs_fz} {#SGSYS-endOfThisYear__table_wqv_wbs_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC in the format yyyy-mm-dd hh:mm:ss |
[Table 64. Returns]

{#SGSYS-endOfThisYear__table_wqv_wbs_fz}

## Scoped GlideSystem - error(String message, Object parm1, Object parm2, Object parm3, Object
parm4, Object parm5) {#ariaid-title34}

Writes an error message to the system log.
This method accepts up to five variable arguments (varargs) in the message using the Java
MessageFormat placeholder replacement pattern.  
Note:  
Variables must contain valid values for this method to provide correct output.
{#r_ScopedGlideSystemError_String_Object_Object_Object_Object_Object__table_q24_hvh_1r__entry__3}

| Name | Type | Description |
|-|-|-|
| message | String | The log message with place holders for any variable arguments. |
| param1 | Object | (Optional) First variable argument. |
| param2 | Object | (Optional) Second variable argument. |
| param3 | Object | (Optional) Third variable argument. |
| param4 | Object | (Optional) Fourth variable argument. |
| param5 | Object | (Optional) Fifth variable argument. |
[Table 65. Parameters]

{#r_ScopedGlideSystemError_String_Object_Object_Object_Object_Object__table_q24_hvh_1r} {#r_ScopedGlideSystemError_String_Object_Object_Object_Object_Object__table_ecy_qhr_2r__entry__2}

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

{#r_ScopedGlideSystemError_String_Object_Object_Object_Object_Object__table_ecy_qhr_2r}  

    gs.error("This is an error message");
    var myFirstName = "Abel";
    var myLastName = "Tuter";
    gs.error("This is an error message from {0}.{1}", myFirstName, myLastName);

Output:

    This is an error message
    This is an error message from Abel.Tuter

## Scoped GlideSystem - eventQueue(String name, Object instance, String parm1, String parm2,
String queue) {#ariaid-title35}

Queues an event for the event manager.
{#r_ScopedGlideSystemEventQueue_String_Object_String_String_String__table_ccs_4hh_1r__entry__3}

| Name | Type | Description |
|-|-|-|
| name | String | Name of the event being queued. |
| instance | Object | GlideRecord object, such as "current". |
| parm1 | String | Optional. Saved with the instance if specified. |
| parm2 | String | Optional. Saved with the instance if specified. |
| queue | String | Optional. Name of the queue. |
[Table 67. Parameters]

{#r_ScopedGlideSystemEventQueue_String_Object_String_String_String__table_ccs_4hh_1r} {#r_ScopedGlideSystemEventQueue_String_Object_String_String_String__table_hzd_shr_2r__entry__2}

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

{#r_ScopedGlideSystemEventQueue_String_Object_String_String_String__table_hzd_shr_2r}  

    if (current.operation() != 'insert' && current.comments.changes()) {
        gs.eventQueue('incident.commented', current, gs.getUserID(), gs.getUserName());
    }

## Scoped GlideSystem - eventQueueScheduled(String name, Object instance, String parm1, String
parm2, Object expiration) {#ariaid-title36}

Queues an event in the event manager.
The passed in event schedule information is stored in the Events \[sysevent\] table. For
additional information on events, see [Events](https://www.servicenow.com/docs/access?context=events&version=australia&pubname=australia-build-workflows&ft:locale=en-US).
{#r_SGSYS-eventQSched_S_O_S_S_O__table_nxv_r3k_bx__entry__3}

| Name | Type | Description |
|-|-|-|
| name | String | Name of the event to queue. |
| instance | Object/String | GlideRecord object or the sys_id of the record to which this event applies. |
| parm1 | String | Optional. String to pass into the event script. This parameter is free-form and depends on the implementation of the event script. Default: If the instance parameter is a GlideRecord object, then the default is the display value for that GlideRecord (now_GR.getDisplayValue) otherwise it is `null`. |
| parm2 | String | Optional. String to pass into the event script. This parameter is free-form and depends on the implementation of the event script. Default: `null` |
| expiration | Object | Optional. GlideDateTime object or a date/time type element that specifies the date and time to process the event. Default: Current date/time |
[Table 69. Parameters]

{#r_SGSYS-eventQSched_S_O_S_S_O__table_nxv_r3k_bx} {#r_SGSYS-eventQSched_S_O_S_S_O__table_oxv_r3k_bx__entry__2}

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

{#r_SGSYS-eventQSched_S_O_S_S_O__table_oxv_r3k_bx}  
This example shows how to call the method using a GlideRecord, two parameters that are
passed to the event script, and a specified time to schedule the event.

    var requestXml = requestBody.dataString;
    var processTime = new GlideDateTime();
    processTime.addDaysLocalTime(7);
    gs.eventQueueScheduled('sn_app.user.deactivate', now_GR, requestXML, gs.getUserID(), processTime);

This example shows how to call the method using a sys_id and the default values for the
optional parameters.

    gs.eventQueueScheduled('event.test', '0e29421383101000dada83ec37d9292d', '', '', '');

## Scoped GlideSystem - executeNow(GlideRecord job) {#ariaid-title37}

Executes a job for a scoped application.
You can only use this method on a job in the same application as the script calling this
method.
{#r_SGSYS-executeNow_GR__table_nh4_3gf_2v__entry__3}

| Name | Type | Description |
|-|-|-|
| job | GlideRecord | Job to run. |
[Table 71. Parameters]

{#r_SGSYS-executeNow_GR__table_nh4_3gf_2v} {#r_SGSYS-executeNow_GR__table_oh4_3gf_2v__entry__2}

| Type | Description |
|-|-|
| String | Returns the sys_id of the scheduled job. Returns null if the job is global. |
[Table 72. Returns]

{#r_SGSYS-executeNow_GR__table_oh4_3gf_2v}  

    scheduleImportJob: function () {
      var jobId = '61847fe04c603300fa9bb64c2b491dac';
      var now_GR = new GlideRecord('sysauto_script');
      if (!now_GR.get(jobId)) {
        throw new Error('Unable to find import job');
      }
      gs.executeNow(now_GR);
    }

## Scoped GlideSystem - generateGUID() {#ariaid-title38}

Generates a GUID that can be used when a unique identifier is required.
{#r_ScopedGlideSystemGenerateGUID__table_wkv_psb_2r__entry__3}

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

{#r_ScopedGlideSystemGenerateGUID__table_wkv_psb_2r} {#r_ScopedGlideSystemGenerateGUID__table_gg4_gnh_1r__entry__2}

| Type | Description |
|-|-|
| String | A 32-character hexadecimal GUID. |
[Table 74. Returns]

{#r_ScopedGlideSystemGenerateGUID__table_gg4_gnh_1r}  
The following code example shows how to call this method.

    personalId = gs.generateGUID();
    gs.info(personalId);

Output:

    af770511ff013100e04bfffffffffff6

## Scoped GlideSystem - getCallerScopeName() {#ariaid-title39}

Gets the caller scope name; returns null if there is no caller.
{#r_ScopedGlideSystemGetCallerScopeName__table_s5q_psb_2r__entry__3}

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

{#r_ScopedGlideSystemGetCallerScopeName__table_s5q_psb_2r} {#r_ScopedGlideSystemGetCallerScopeName__table_slj_2qh_1r__entry__2}

| Type | Description |
|-|-|
| String | The caller's scope name, or null if there is no caller. |
[Table 76. Returns]

{#r_ScopedGlideSystemGetCallerScopeName__table_slj_2qh_1r}  
This example shows two script includes that are set to Accessible from all application
scopes. One script include is created within app_scope_a.

    var Scopea = Class.create(); 
     
    Scopea.prototype = { 
        initialize: function() { 
        }, 
     
        callerScope: function() { 
            var scopeb = new app_scope_b.Scopeb(); 
            return scopeb.callerscope(); 
        }, 
     
        type: 'Scopea' 
    }

Output:  
This example shows another script include created within app_scope_b.

    var Scopeb = Class.create(); 
     
    Scopeb.prototype = { 
        initialize: function() { 
            this._constructorCallerScope = gs.getCallerScopeName(); 
        }, 
     
        callerscope: function() { 
            return gs.getCallerScopeName(); 
        }, 
     
        getConstructorCallerScope: function() { 
            return this._constructorCallerScope; 
        }, 
     
        type: 'Scopeb' 
    }

Output:  
This script can be used within scope app_scope_a to get the scope name of the caller---in
this case app_scope_b.

    gs.info(new Scopea().getCallerScopeName());

## Scoped GlideSystem - getCssCacheVersionString() {#ariaid-title40}

Gets a string representing the cache version for a CSS file.
{#r_ScopedGlideSystemGetCssCacheVersionString__table_uwl_psb_2r__entry__3}

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

{#r_ScopedGlideSystemGetCssCacheVersionString__table_uwl_psb_2r} {#r_ScopedGlideSystemGetCssCacheVersionString__table_h2b_d4h_1r__entry__2}

| Type | Description |
|-|-|
| String | The CSS cache version. |
[Table 78. Returns]

{#r_ScopedGlideSystemGetCssCacheVersionString__table_h2b_d4h_1r}  
The following code example shows how to call this method.

    var verStr = gs.getCssCacheVersionString();
    gs.info(verStr);

Output:

    _d82979516f0171005be8883e6b3ee4cf&theme=

## Scoped GlideSystem - getCurrentApplicationId() {#ariaid-title41}

Gets the ID of the current application as set using the Application Picker.
{#r_ScopedGlideSystemGetCurrentApplicationId__table_glf_psb_2r__entry__3}

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

{#r_ScopedGlideSystemGetCurrentApplicationId__table_glf_psb_2r} {#r_ScopedGlideSystemGetCurrentApplicationId__table_bdg_54h_1r__entry__2}

| Type | Description |
|-|-|
| String | The current application's sys_id, or global in none is set. |
[Table 80. Returns]

{#r_ScopedGlideSystemGetCurrentApplicationId__table_bdg_54h_1r}  

    var currentId = gs.getCurrentApplicationId();
    gs.info(currentId);

Output

    04936cb16f30b1005be8883e6b3ee4e0

## Scoped GlideSystem - getCurrentScopeName() {#ariaid-title42}

Gets the name of the current scope.
{#r_ScopedGlideSystemGetCurrentScopeName__table_yly_4sb_2r__entry__3}

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

{#r_ScopedGlideSystemGetCurrentScopeName__table_yly_4sb_2r} {#r_ScopedGlideSystemGetCurrentScopeName__table_rgf_sph_1r__entry__2}

| Type | Description |
|-|-|
| String | The current scope name. |
[Table 82. Returns]

{#r_ScopedGlideSystemGetCurrentScopeName__table_rgf_sph_1r}  
The following code example shows how to call this method.

    var currentScope = gs.getCurrentScopeName();
    gs.info(currentScope);

Output:

    s_snc_test_scope

## Scoped GlideSystem - getDateFormat(String) {#ariaid-title43}

Returns the date format associated with the current user.
{#SGSYS-getDateFormat_S__entry__3}

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

{#SGSYS-getDateFormat_S__entry__8}

| Type | Description |
|-|-|
| String | The date format associated with the current user. |
[Table 84. Returns]

The following example returns the date format associated with the user.

    var userDateFormat = gs. getDateFormat();
    gs.info(userDateFormat);

Output:

    yyyy-MM-dd

## Scoped GlideSystem - getDateTimeFormat() {#ariaid-title44}

Returns the date and time format associated with the current user.
{#SGSYS-getDateTimeFormat_S__table_lcm_2np_m5b__entry__3}

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

{#SGSYS-getDateTimeFormat_S__table_lcm_2np_m5b} {#SGSYS-getDateTimeFormat_S__table_mcm_2np_m5b__entry__2}

| Type | Description |
|-|-|
| String | The date and time format associated with the current user. |
[Table 86. Returns]

{#SGSYS-getDateTimeFormat_S__table_mcm_2np_m5b}  
The following example returns the format of the date and time that is associated with the
user.

    var userDateTimeFormat = gs.getDateTimeFormat();
    gs.info(userDateTimeFormat);

Output:

    yyyy-MM-dd HH:mm:ss

## Scoped GlideSystem - getErrorMessages() {#ariaid-title45}

Returns the error messages that were added by addErrorMessage() for
the session.
{#SGSYS-getErrorMessages__table_wwh_tpx_fz__entry__3}

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

{#SGSYS-getErrorMessages__table_wwh_tpx_fz} {#SGSYS-getErrorMessages__table_xwh_tpx_fz__entry__2}

| Type | Description |
|-|-|
| Array of Strings | Error messages associated with the session. |
[Table 88. Returns]

{#SGSYS-getErrorMessages__table_xwh_tpx_fz}

## Scoped GlideSystem - getEscapedMessage(String id, Array args) {#ariaid-title46}

Retrieves the specified message from the Message \[sys_ui_message\] table. If the message
has HTML special characters, replaces them with the corresponding HTML name codes. For example,
`&` becomes `&amp;`.
If the specified message identifier (Key) exists in the Message \[sys_ui_message\] table for the current language, the method returns the translated message with all special
characters returned as escape sequences. If the specified message identifier does not exist for the current language, then the method returns the English version of the message with all special characters returned
as escape sequences. If the message identifier does not exist in the table, then it returns the message ID.

For additional information about the Message table, see [Message table](https://www.servicenow.com/docs/access?context=r_MessageTable&version=australia&pubname=australia-platform-administration&ft:locale=en-US).  
Note:  
If the UI message has a tick ('), there may be issues with the message in the script; to escape the ticks ('), use getMessageS(String, Object).
{#r_SGSYS-getEscapedMessage_S_O__table_m4y_5rz_5w__entry__3}

| Name | Type | Description |
|-|-|-|
| id | String | Message identifier. You can locate this value in the Key field of the Message \[sys_ui_message\] table. Note the Key field may look exactly like the actual message string. |
| args | Array | Optional. List of strings or other values defined by java.text.MessageFormat that replace the variables within the specified message. For example: `gs.getMessage("Abort adding action '{0}', same subflow can't be added twice in this subflow.", current.action.name);` In this example <var class="keyword varname">'{0}'</var> is replaced with the content of <var class="keyword varname">current.action.name</var>. Note: The passed in values are not translated. They are inserted verbatim in the message. |
[Table 89. Parameters]

{#r_SGSYS-getEscapedMessage_S_O__table_m4y_5rz_5w} {#r_SGSYS-getEscapedMessage_S_O__table_n4y_5rz_5w__entry__2}

| Type | Description |
|-|-|
| String | UI message with HTML special characters replaced with HTML name codes. |
[Table 90. Returns]

{#r_SGSYS-getEscapedMessage_S_O__table_n4y_5rz_5w}  
This example shows the ampersand character being replaced with the equivalent ampersand
HTML name code.

    var my_message = gs.getEscapedMessage("Is the summary & details accurate?");
    alert(my_message);

Output

    Is the summary &amp; details accurate?

This example shows how to replace a single variable within a message and how the \< and \>
symbols in the message are transposed to the corresponding HTML name codes of \&lt and
\&gt.

    // current.action.name is "update record"
    var my_message = gs.getEscapedMessage("Abort adding action '{0}', same <subflow> can't be added twice in this subflow.", current.action.name);
    alert(my_message);

Output

    Abort adding action update record, same &ltsubflow&gt can't be added twice in this subflow.

## Scoped GlideSystem - getMessage(String id, Array args) {#ariaid-title47}

Retrieves translated messages from the Message \[sys_ui_message\] table to display in a
UI.
If the specified message identifier (key) exists in the Message \[sys_ui_message\] table for
the current language, then the method returns the translated message. If the specified
message identifier does not exist for the current language, then the method returns the
English version of the message. If the message identifier does not exist in the table, then
it returns the message ID.

For additional information about the Message table, see [Message table](https://www.servicenow.com/docs/access?context=r_MessageTable&version=australia&pubname=australia-platform-administration&ft:locale=en-US)  
Note:  
If the UI message has a tick ('), there may be issues with the message in the script; to escape the ticks ('), use getMessageS(String, Object).
{#r_ScopedGlideSystemGetMessage_String_Object__table_nwm_grh_1r__entry__3}

| Name | Type | Description |
|-|-|-|
| id | String | Message identifier. You can locate this value in the Key field of the Message \[sys_ui_message\] table. Note the Key field may look exactly like the actual message. |
| args | Array | Optional. List of strings or other values defined by java.text.MessageFormat that replace the variables within the specified message. For example: `gs.getMessage("Abort adding action '{0}', same subflow can't be added twice in this subflow.", current.action.name);` In this example <var class="keyword varname">'{0}'</var> is replaced with the content of <var class="keyword varname">current.action.name</var>. Note: The passed in values are not translated. They are inserted verbatim in the message. |
[Table 91. Parameters]

{#r_ScopedGlideSystemGetMessage_String_Object__table_nwm_grh_1r} {#r_ScopedGlideSystemGetMessage_String_Object__table_pwm_grh_1r__entry__2}

| Type | Description |
|-|-|
| String | UI message. |
[Table 92. Returns]

{#r_ScopedGlideSystemGetMessage_String_Object__table_pwm_grh_1r}  
This example shows the message returned for the current user when Spanish is the current
language.

    var my_message = gs.getMessage("rows will not be updated");
    alert(my_message);

Output:

    las filas no se actualizarán

This example shows how to replace a single variable within a message.

    // current.action.name is "update record"
    var my_message = gs.getMessage("Abort adding action '{0}', same subflow can't be added twice in this subflow.", current.action.name);
    alert(my_message);

Output:

    Abort adding action update record, same subflow can't be added twice in this subflow.

This example shows how to replace multiple variables within a message.

    // current.sub_flow.name is 'schedule users'
    // current.action.name is "update record"
    var my_message = gs.getEscapedMessage("Abort adding action '{0}', same subflow can't be added twice in {1} subflow.", [current.action.name, current.sub_flow.name]);
    alert(my_message);

Output:

    Abort adding action update record, same subflow can't be added twice in schedule users subflow.

## Scoped GlideSystem - getProperty(String key, Object alt) {#ariaid-title48}

Gets the value of a Glide property. If the property is not found, returns an alternate
value.
{#r_ScopedGlideSystemGetProperty_String_Object__table_vwr_2sh_1r__entry__3}

| Name | Type | Description |
|-|-|-|
| key | String | The key for the property whose value should be returned. |
| alt | Object | (Optional) Alternate object to return if the property is not found. |
[Table 93. Parameters]

{#r_ScopedGlideSystemGetProperty_String_Object__table_vwr_2sh_1r} {#r_ScopedGlideSystemGetProperty_String_Object__table_xwr_2sh_1r__entry__2}

| Type | Description |
|-|-|
| String | The value of the Glide property, or the alternate object defined above. |
[Table 94. Returns]

{#r_ScopedGlideSystemGetProperty_String_Object__table_xwr_2sh_1r}  
The following code example shows how to call this method.

    var attachment_link = gs.getProperty('glide.servlet.uri');
    gs.info(attachment_link);

Output:

    https://instance.service-now.com/

## Scoped GlideSystem - getSession() {#ariaid-title49}

Gets a reference to the current Glide session.
{#r_ScopedGlideSystemGetSession__table_apr_4sb_2r__entry__3}

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

{#r_ScopedGlideSystemGetSession__table_apr_4sb_2r} {#r_ScopedGlideSystemGetSession__table_rc2_gtm_1r__entry__2}

| Type | Description |
|-|-|
| String | A reference for the current session. |
[Table 96. Returns]

{#r_ScopedGlideSystemGetSession__table_rc2_gtm_1r}  

    if (!gs.hasRole("admin") && !gs.hasRole("user_admin") && gs.getSession().isInteractive()) {
      current.addQuery("active", "true");
    }

## Scoped GlideSystem - getSessionID() {#ariaid-title50}

Retrieves the GlideSession session ID.
{#r_ScopedGlideSystemGetSessionID__table_dgm_4sb_2r__entry__3}

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

{#r_ScopedGlideSystemGetSessionID__table_dgm_4sb_2r} {#r_ScopedGlideSystemGetSessionID__table_jdz_qtm_1r__entry__2}

| Type | Description |
|-|-|
| String | The session ID. |
[Table 98. Returns]

{#r_ScopedGlideSystemGetSessionID__table_jdz_qtm_1r}  

    var myUserObject = gs.getSessionID();
    gs.info(myUserObject);

Output:

    A0D4E5416F3F21005BE8883E6B3EE4B8

## Scoped GlideSystem - getSessionToken() {#ariaid-title51}

This method is no longer available. Instead, use
`gs.getSession().getSessionToken()`.
{#r_ScopedGlideSystemGetSessionToken__table_jhq_msb_2r__entry__3}

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

{#r_ScopedGlideSystemGetSessionToken__table_jhq_msb_2r} {#r_ScopedGlideSystemGetSessionToken__table_ylr_25m_1r__entry__2}

| Type | Description |
|-|-|
| String | The session token. |
[Table 100. Returns]

{#r_ScopedGlideSystemGetSessionToken__table_ylr_25m_1r}

## Scoped GlideSystem - getTimeFormat() {#ariaid-title52}

Returns the time format associated with the current user.
{#SGSYS-getTimeFormat_S__table_j1c_bht_q5b__entry__3}

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

{#SGSYS-getTimeFormat_S__table_j1c_bht_q5b} {#SGSYS-getTimeFormat_S__table_k1c_bht_q5b__entry__2}

| Type | Description |
|-|-|
| String | The time format associated with the current user. |
[Table 102. Returns]

{#SGSYS-getTimeFormat_S__table_k1c_bht_q5b}  
The following code example shows how to call this method.

    var userTimeFormat = gs. getTimeFormat();
    gs.info(userTimeFormat);

Output:

    HH:mm:ss

## Scoped GlideSystem - getTimeZoneName() {#ariaid-title53}

Returns the name of the time zone associated with the current user.
This method has been deprecated. Instead, use the [getTimeZoneName()](https://www.servicenow.com/docs/fz3ovhTPoOExF0BH5uOEFw#r_ScopedGlideSessionGetTimeZoneName "Returns the name of the session's time zone.") method in the GlideSession API.
{#r_ScopedGlideSystemGetTimeZoneName__table_iwl_msb_2r__entry__3}

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

{#r_ScopedGlideSystemGetTimeZoneName__table_iwl_msb_2r} {#r_ScopedGlideSystemGetTimeZoneName__table_c4q_r5m_1r__entry__2}

| Type | Description |
|-|-|
| String | The time zone name. |
[Table 104. Returns]

{#r_ScopedGlideSystemGetTimeZoneName__table_c4q_r5m_1r}  
The following code example shows how to call this method.

    gs.info(gs.getTimeZoneName());

## Scoped GlideSystem - getUrlOnStack() {#ariaid-title54}

Gets the current URI for the session.
{#r_ScopedGlideSystemGetUrlOnStack__table_kwf_msb_2r__entry__3}

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

{#r_ScopedGlideSystemGetUrlOnStack__table_kwf_msb_2r} {#r_ScopedGlideSystemGetUrlOnStack__table_m51_3vm_1r__entry__2}

| Type | Description |
|-|-|
| String | The URI. |
[Table 106. Returns]

{#r_ScopedGlideSystemGetUrlOnStack__table_m51_3vm_1r}  

    gs.info(gs.getUrlOnStack());

## Scoped GlideSystem - getUser() {#ariaid-title55}

Returns a reference to the scoped GlideUser object for the current user.
See [GlideUser - Scoped](https://www.servicenow.com/docs/JC5EY~dyyjYpNgoUpXKwLg#c_GlideUserScopedAPI "The GlideUser API provides methods to access information about the current user and current user roles.")for a list of
available methods.
{#r_ScopedGlideSystemGetUser__table_ec1_msb_2r__entry__3}

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

{#r_ScopedGlideSystemGetUser__table_ec1_msb_2r} {#r_ScopedGlideSystemGetUser__table_lnd_yvm_1r__entry__2}

| Type | Description |
|-|-|
| GlideUser | Reference to a scoped user object. |
[Table 108. Returns]

{#r_ScopedGlideSystemGetUser__table_lnd_yvm_1r}  

    var myUserObject = gs.getUser();
    gs.info(myUserObject);

Output

    com.glide.script.fencing.ScopedUser@6c0645

## Scoped GlideSystem - getUserDisplayName() {#ariaid-title56}

Gets the display name of the current user.
{#r_ScopedGlideSystemGetUserDisplayName__table_syh_jsb_2r__entry__3}

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

{#r_ScopedGlideSystemGetUserDisplayName__table_syh_jsb_2r} {#r_ScopedGlideSystemGetUserDisplayName__table_jtg_pwm_1r__entry__2}

| Type | Description |
|-|-|
| String | The name field of the current user. For example, this method returns Abel Tuter as opposed to abel.tuter. |
[Table 110. Returns]

{#r_ScopedGlideSystemGetUserDisplayName__table_jtg_pwm_1r}  
This example gets the current user's display name.

    gs.info(gs.getUserDisplayName());

Output:

    System Administrator

## Scoped GlideSystem - getUserID() {#ariaid-title57}

Gets the sys_id of the current user.
{#r_ScopedGlideSystemGetUserID__table_t4c_jsb_2r__entry__3}

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

{#r_ScopedGlideSystemGetUserID__table_t4c_jsb_2r} {#r_ScopedGlideSystemGetUserID__table_bbh_cxm_1r__entry__2}

| Type | Description |
|-|-|
| String | The sys_id of the current user. |
[Table 112. Returns]

{#r_ScopedGlideSystemGetUserID__table_bbh_cxm_1r}  
The following example shows how to unassign all active Incident records assigned to the
current user.

    var incidentGR = new GlideRecord('incident');
    incidentGR.addActiveQuery();

    // Filter results to incidents assigned to the current user
    var currentUserSysId = gs.getUserID();
    incidentGR.addQuery('assigned_to', currentUserSysId);
    incidentGR.query();

    while (incidentGR.next()) {
        incidentGR.setValue('assigned_to', 'NULL');
        incidentGR.update();
        gs.info(
            'Unassigned Incident: {0}: {1}',
            incidentGR.number.toString(),
            incidentGR.short_description.toString()
        );
    }

Output:

    Unassigned Incident: INC0000057: Performance problems with wifi
    Unassigned Incident: INC0009001: Unable to post content on a Wiki page
    Unassigned Incident: INC0008111: ATF : Test1

## Scoped GlideSystem - getUserName() {#ariaid-title58}

Returns the user name of the current user.
{#r_ScopedGlideSystemGetUserName__table_khy_3sb_2r__entry__3}

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

{#r_ScopedGlideSystemGetUserName__table_khy_3sb_2r} {#r_ScopedGlideSystemGetUserName__table_u4c_mxm_1r__entry__2}

| Type | Description |
|-|-|
| String | The user name of the current user. For example, this method returns abel.tuter as opposed to Abel Tuter. |
[Table 114. Returns]

{#r_ScopedGlideSystemGetUserName__table_u4c_mxm_1r}  
This example gets the user name of the current user.

    gs.info("The current user name is: " + gs.getUserName());

Output:

    The current user name is: admin

## Scoped GlideSystem - hasRole(Object role) {#ariaid-title59}

Determines if the current user has the specified role.
{#r_ScopedGlideSystemHasRole_Object__table_bqc_xxm_1r__entry__3}

| Name | Type | Description |
|-|-|-|
| role | Object | The role to check. |
[Table 115. Parameters]

{#r_ScopedGlideSystemHasRole_Object__table_bqc_xxm_1r} {#r_ScopedGlideSystemHasRole_Object__table_dqc_xxm_1r__entry__2}

| Type | Description |
|-|-|
| Boolean | True if the user had the role. Returns true for users with the administrator role. |
[Table 116. Returns]

{#r_ScopedGlideSystemHasRole_Object__table_dqc_xxm_1r}  

    if (!gs.hasRole("admin") && !gs.hasRole("groups_admin")  && gs.getSession().isInteractive()) {
      var qc = current.addQuery("u_hidden", "!=", "true"); //cannot see hidden groups... 
      qc.addOrCondition("sys_id", "javascript:getMyGroups()"); //...unless in the hidden group
      gs.info("User has admin and groups admin roles");
    }
    else {
      gs.info("User does not have both admin and groups admin roles");
    }

## Scoped GlideSystem - hoursAgo(Number hours) {#ariaid-title60}

Returns the date and time for a specified number of hours ago. Returned in the user's session time zone as a UTC timestamp.
{#SGSYS-hoursAgo_N__table_lvt_yqx_fz__entry__3}

| Name | Type | Description |
|-|-|-|
| hours | Number | Integer number of hours |
[Table 117. Parameters]

{#SGSYS-hoursAgo_N__table_lvt_yqx_fz} {#SGSYS-hoursAgo_N__table_mvt_yqx_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC in the format yyyy-mm-dd hh:mm:ss |
[Table 118. Returns]

{#SGSYS-hoursAgo_N__table_mvt_yqx_fz}  

    if (current.operation() == 'insert') {
     // If no due date was specified, calculate a default
     if (current.due_date == '') {
     
      if (current.urgency == '1') {
       // Set due date to 4 hours ahead of current time
       current.due_date = gs.hoursAgo(-4);
      }
     
      if (current.urgency == '2') {
       // Set due date to 2 days ahead of current time
       current.due_date = gs.daysAgo(-2);
      }
     
      if (current.urgency == '3') {
       // Set due date to 7 days ahead of current time
       current.due_date = gs.daysAgo(-7);
      }
     }
    }

## Scoped GlideSystem - hoursAgoEnd(Number hours) {#ariaid-title61}

Returns the date and time for the end of the hour a specified number of hours ago. Returned in the user's session time zone as a UTC timestamp.
{#SGSYS-hoursAgoEnd_N__table_pd3_ytx_fz__entry__3}

| Name | Type | Description |
|-|-|-|
| hours | Number | Integer number of hours |
[Table 119. Parameters]

{#SGSYS-hoursAgoEnd_N__table_pd3_ytx_fz} {#SGSYS-hoursAgoEnd_N__table_qd3_ytx_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC in the format yyyy-mm-dd hh:mm:ss |
[Table 120. Returns]

{#SGSYS-hoursAgoEnd_N__table_qd3_ytx_fz}

## Scoped GlideSystem - hoursAgoStart(Number hours) {#ariaid-title62}

Returns the date and time for the start of the hour a specified number of hours ago. Returned in the user's session time zone as a UTC timestamp.
{#SGSYS-hoursAgoStart_N__table_uzf_bvx_fz__entry__3}

| Name | Type | Description |
|-|-|-|
| hours | Number | Integer number of hours |
[Table 121. Parameters]

{#SGSYS-hoursAgoStart_N__table_uzf_bvx_fz} {#SGSYS-hoursAgoStart_N__table_vzf_bvx_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC in the format yyyy-mm-dd hh:mm:ss |
[Table 122. Returns]

{#SGSYS-hoursAgoStart_N__table_vzf_bvx_fz}

## Scoped GlideSystem - include(String name) {#ariaid-title63}

Provides a safe way to call a script include from the sandbox, allowing only the
inclusion of trusted scripts.
{#r_ScopedGlideSystemInclude_String__table_x5p_2th_1r__entry__3}

| Name | Type | Description |
|-|-|-|
| name | String | Name of the script to include. |
[Table 123. Parameters]

{#r_ScopedGlideSystemInclude_String__table_x5p_2th_1r} {#r_ScopedGlideSystemInclude_String__table_z5p_2th_1r__entry__2}

| Type | Description |
|-|-|
| Boolean | Flag that indicates whether the script include worked. Possible values: * true: Script include worked. * false: Script include failed. {#r_ScopedGlideSystemInclude_String__ul_pmy_h5c_z4b} |
[Table 124. Returns]

{#r_ScopedGlideSystemInclude_String__table_z5p_2th_1r}  
This example gets the LDAPUtils in the current script context.

    var ldapServer = new GlideRecord("ldap_server_config");
    ldapServer.addActiveQuery();
    ldapServer.query();
    gs.include("LDAPUtils");
    var ldapUtils = new LDAPUtils();
    var errMsg = "";
    while (ldapServer.next()) {
      var ldap = new GlideLDAP();
      var dn = ldapServer.dn;
      var env = ldap.setup();
      if (env == null) {
        errMsg = "Failed environment setup, missing URL";
        gs.eventQueue("ldap.connection_failed",   ldapServer, ldapServer.getDisplayValue(), errMsg);
        gs.logError("LDAP server " + ldapServer.getDisplayValue() + " failed scheduled connection test: " + errMsg, "LDAP");
     }
    }

## Scoped GlideSystem - info(String message, Object parm1, Object parm2, Object parm3, Object
parm4, Object parm5) {#ariaid-title64}

Writes an info message to the system log.
{#r_ScopedGlideSystemInf_String_Object_Object_Object_Object_Object__table_e1z_txh_1r__entry__3}

| Name | Type | Description |
|-|-|-|
| message | String | The log message with place holders for any variable arguments. |
| param1 | Object | (Optional) First variable argument. |
| param2 | Object | (Optional) Second variable argument. |
| param3 | Object | (Optional) Third variable argument. |
| param4 | Object | (Optional) Fourth variable argument. |
| param5 | Object | (Optional) Fifth variable argument. |
[Table 125. Parameters]

{#r_ScopedGlideSystemInf_String_Object_Object_Object_Object_Object__table_e1z_txh_1r} {#r_ScopedGlideSystemInf_String_Object_Object_Object_Object_Object__table_xjc_t3r_2r__entry__2}

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

{#r_ScopedGlideSystemInf_String_Object_Object_Object_Object_Object__table_xjc_t3r_2r}  

    gs.info("This is an info message");
    var myFirstName = "Abel";
    var myLastName = "Tuter";
    gs.info("This is an info message from {0}.{1}", myFirstName, myLastName);

Output:

    This is an info message
    This is an info message from Abel.Tuter

## Scoped GlideSystem - isDebugging() {#ariaid-title65}

Determines if debugging is active for a specific scope.
{#r_ScopedGlideSystemIsDebugging__table_fth_3sb_2r__entry__3}

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

{#r_ScopedGlideSystemIsDebugging__table_fth_3sb_2r} {#r_ScopedGlideSystemIsDebugging__table_ols_hzh_1r__entry__2}

| Type | Description |
|-|-|
| Boolean | True if either session debugging is active or the log level is set to debug for the specified scope. |
[Table 128. Returns]

{#r_ScopedGlideSystemIsDebugging__table_ols_hzh_1r}  

    gs.debug("This is a log message");
    var myFirstName = "Abel";
    var myLastName = "Tuter";
    gs.debug("This is a log message from {0}.{1}", myFirstName, myLastName);
    gs.info(gs.isDebugging());

## Scoped GlideSystem - isInteractive() {#ariaid-title66}

Checks if the current session is interactive. An example of an interactive session is
when a user logs in normally. An example of a non-interactive session is using a SOAP request to
retrieve data.
{#r_ScopedGlideSystemIsInteractive__table_crt_hsb_2r__entry__3}

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

{#r_ScopedGlideSystemIsInteractive__table_crt_hsb_2r} {#r_ScopedGlideSystemIsInteractive__table_wkv_lym_1r__entry__2}

| Type | Description |
|-|-|
| Boolean | True if the session is interactive. |
[Table 130. Returns]

{#r_ScopedGlideSystemIsInteractive__table_wkv_lym_1r}  

    if (!gs.hasRole("admin") && gs.getSession().isInteractive()) {
        var qc1 = current.addQuery('u_group',"");
        var gra = new GlideRecord('sys_user_grmember');
        gra.addQuery('user', gs.getUserID());
        gra.query();
        while (gra.next()) {
            qc1.addOrCondition('u_group', gra.group);
        }
    }

## Scoped GlideSystem - isLoggedIn() {#ariaid-title67}

Determines if the current user is currently logged in.
{#r_ScopedGlideSystemIsLoggedIn__table_skl_hsb_2r__entry__3}

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

{#r_ScopedGlideSystemIsLoggedIn__table_skl_hsb_2r} {#r_ScopedGlideSystemIsLoggedIn__table_a4g_zym_1r__entry__2}

| Type | Description |
|-|-|
| Boolean | True if the current user is logged in. |
[Table 132. Returns]

{#r_ScopedGlideSystemIsLoggedIn__table_a4g_zym_1r}  

    gs.info(gs.isLoggedIn());

## Scoped GlideSystem - isMobile() {#ariaid-title68}

You can determine if a request comes from a mobile device.
This method can be used in UI action conditions and business rules.
{#r_ScopedGS-isMobile__table_svk_zcz_bv__entry__3}

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

{#r_ScopedGS-isMobile__table_svk_zcz_bv} {#r_ScopedGS-isMobile__table_tvk_zcz_bv__entry__2}

| Type | Description |
|-|-|
| Boolean | True if the request comes from a mobile device; otherwise, false. |
[Table 134. Returns]

{#r_ScopedGS-isMobile__table_tvk_zcz_bv}  

    if (gs.isMobile())
      gs.info("submitted from mobile UI");
     else 
       gs.info("NOT submitted from mobile UI");

Output

    NOT submitted from mobile UI

## Scoped GlideSystem - minutesAgoEnd(Number minutes) {#ariaid-title69}

Returns the date and time for the end of the minute a specified number of minutes ago. Returned in the user's session time zone as a UTC timestamp.
{#SGSYS-minutesAgoEnd_N__table_x1y_pny_fz__entry__3}

| Name | Type | Description |
|-|-|-|
| minutes | Number | Integer number of minutes ago, such as 5 or 126. |
[Table 135. Parameters]

{#SGSYS-minutesAgoEnd_N__table_x1y_pny_fz} {#SGSYS-minutesAgoEnd_N__table_y1y_pny_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC the specified number of minutes ago, at the end of the minute (59 seconds). Format: yyyy-mm-dd hh:mm:ss |
[Table 136. Returns]

{#SGSYS-minutesAgoEnd_N__table_y1y_pny_fz}  
The following example displays the current date and time and the date and time 30 minutes ago at the end of the minute in UTC.

    var nowDateTime = new GlideDateTime();
    gs.info("Now: " + nowDateTime);
    var thirtyMinutesAgoDateTime = gs.minutesAgoEnd(30);
    gs.info("Thirty minutes ago end time: " + thirtyMinutesAgoDateTime);

Output:

    Now: 2021-10-20 15:22:13
    Thirty minutes ago end time: 2021-10-20 14:52:59

## Scoped GlideSystem - minutesAgoStart(Number minutes) {#ariaid-title70}

Returns the date and time for the start of the minute a specified number of minutes ago. Returned in the user's session time zone as a UTC timestamp.
{#SGSYS-minutesAgoStart_N__table_lhk_2py_fz__entry__3}

| Name | Type | Description |
|-|-|-|
| minutes | Number | Integer number of minutes ago, such as 15 or 112. |
[Table 137. Parameters]

{#SGSYS-minutesAgoStart_N__table_lhk_2py_fz} {#SGSYS-minutesAgoStart_N__table_mhk_2py_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC the specified number of minutes ago, at the start of the minute. Format: yyyy-mm-dd hh:mm:ss |
[Table 138. Returns]

{#SGSYS-minutesAgoStart_N__table_mhk_2py_fz}  
The following example displays the current date and time and the date and time 30 minutes ago at the start of the minute in UTC.

    var nowDateTime = new GlideDateTime();
    gs.info("Now: " + nowDateTime);
    var thirtyMinutesAgoDateTime = gs.minutesAgoStart(30);
    gs.info("Thirty minutes ago: " + thirtyMinutesAgoDateTime);

Output:

    Now: 2021-10-20 14:56:18
    Thirty minutes ago: 2021-10-20 14:26:00

## Scoped GlideSystem - monthsAgo(Number months) {#ariaid-title71}

Returns the date and time for a specified number of months ago in the user's session time zone as a UTC timestamp.
{#SGSYS-monthsAgo_N__table_vyz_xpy_fz__entry__3}

| Name | Type | Description |
|-|-|-|
| months | Number | Integer number of months ago. |
[Table 139. Parameters]

{#SGSYS-monthsAgo_N__table_vyz_xpy_fz} {#SGSYS-monthsAgo_N__table_wyz_xpy_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC of the specified number of months ago at the exact same time. Format: yyyy-mm-dd hh:mm:ss |
[Table 140. Returns]

{#SGSYS-monthsAgo_N__table_wyz_xpy_fz}  
The following example displays the current date and time and the date and time one month ago at the same time in UTC.

    var nowDateTime = new GlideDateTime();
    gs.info("Now: " + nowDateTime);
    var oneMonthAgoDateTime = gs.monthsAgo(1);
    gs.info("One month ago: " + oneMonthAgoDateTime);

Output:

    Now: 2021-10-20 15:29:15
    One month ago: 2021-09-20 15:29:15

## Scoped GlideSystem - monthsAgoEnd(Number months) {#ariaid-title72}

Returns the date and time for the last day of the month a specified number of months ago.
{#SGSYS-monthsAgoEnd_N__table_vwt_ccv_22c__entry__3}

| Name | Type | Description |
|-|-|-|
| months | Number (Integer) | Number of months, such as 4 or 16. |
[Table 141. Parameters]

{#SGSYS-monthsAgoEnd_N__table_vwt_ccv_22c} {#SGSYS-monthsAgoEnd_N__table_wwt_ccv_22c__entry__2}

| Type | Description |
|-|-|
| String | Date and time stamp of the month, the specified number of months ago, in local time. Format: UTC yyyy-mm-dd hh:mm:ss |
[Table 142. Returns]

{#SGSYS-monthsAgoEnd_N__table_wwt_ccv_22c}  
The following example displays the current date and time and the date and time two months ago at the end of the business month.

    var nowDateTime = new GlideDateTime();
    gs.info("Now: " + nowDateTime);
    var endOfTheMonthDateTime = gs.monthsAgoEnd(2);
    gs.info("End of the month: " + endOfTheMonthDateTime);

Output:

    Now: 2021-10-20 19:23:35
    End of the month: 2021-08-01 06:59:59

## Scoped GlideSystem - monthsAgoStart(Number months) {#ariaid-title73}

Returns the date and time for the start of the month a specified number of months ago. Returned in the user's session time zone as a UTC timestamp.
{#SGSYS-monthsAgoStart_N__table_hr4_5ry_fz__entry__3}

| Name | Type | Description |
|-|-|-|
| months | Number | Integer number of months ago, such as 3 or 14. |
[Table 143. Parameters]

{#SGSYS-monthsAgoStart_N__table_hr4_5ry_fz} {#SGSYS-monthsAgoStart_N__table_ir4_5ry_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC start of the month the specified number of months ago. Format: yyyy-mm-dd hh:mm:ss |
[Table 144. Returns]

{#SGSYS-monthsAgoStart_N__table_ir4_5ry_fz}  
The following example displays the current date and time and the date and time three months ago in UTC.

    var nowDateTime = new GlideDateTime();
    gs.info("Now: " + nowDateTime);
    var threeMonthsAgoDateTime = gs.monthsAgoStart(3);
    gs.info("Three months ago start date and time: " + threeMonthsAgoDateTime);

Output:

    Now: 2021-10-20 15:05:27
    Three months ago start date and time: 2021-07-01 07:00:00

## Scoped GlideSystem - nil(Object o) {#ariaid-title74}

Queries an object and returns true if the object is null, undefined, or contains an
empty string.
{#r_ScopedGlideSystemNil_Object__table_lfm_wth_1r__entry__3}

| Name | Type | Description |
|-|-|-|
| o | Object | The object to check. |
[Table 145. Parameters]

{#r_ScopedGlideSystemNil_Object__table_lfm_wth_1r} {#r_ScopedGlideSystemNil_Object__table_nfm_wth_1r__entry__2}

| Type | Description |
|-|-|
| Boolean | True if the object is null, undefined, or contains an empty string; otherwise, returns false. |
[Table 146. Returns]

{#r_ScopedGlideSystemNil_Object__table_nfm_wth_1r}  

    var now_GR = new GlideRecord();
    gs.info(gs.nil(now_GR));

Output

    true

## Scoped GlideSystem - quartersAgoEnd(Number quarters) {#ariaid-title75}

Returns the date and time for the last day of the quarter for a specified number of quarters ago. Returned in the user's session time zone as a UTC timestamp.
{#SGSYS-quartersAgoEnd_N__table_okh_hty_fz__entry__3}

| Name | Type | Description |
|-|-|-|
| quarters | Number | Integer number of quarters |
[Table 147. Parameters]

{#SGSYS-quartersAgoEnd_N__table_okh_hty_fz} {#SGSYS-quartersAgoEnd_N__table_pkh_hty_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC end of the quarter that was the specified number of quarters ago, in the format yyyy-mm-dd hh:mm:ss |
[Table 148. Returns]

{#SGSYS-quartersAgoEnd_N__table_pkh_hty_fz}

## Scoped GlideSystem - quartersAgoStart(Number quarters) {#ariaid-title76}

Returns the date and time for the first day of the quarter for a specified number of quarters ago. Returned in the user's session time zone as a UTC timestamp.
{#SGSYS-quartersAgoStart_N__table_xpw_k5y_fz__entry__3}

| Name | Type | Description |
|-|-|-|
| quarters | Number | Integer number of quarters |
[Table 149. Parameters]

{#SGSYS-quartersAgoStart_N__table_xpw_k5y_fz} {#SGSYS-quartersAgoStart_N__table_ypw_k5y_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC end of the month that was the specified number of quarters ago, in the format yyyy-mm-dd hh:mm:ss |
[Table 150. Returns]

{#SGSYS-quartersAgoStart_N__table_ypw_k5y_fz}

## Scoped GlideSystem - setProperty(String key, String value, String description) {#ariaid-title77}

Sets the specified key to the specified value if the property is within the script's
scope.
Note:  
Care should be taken when setting system properties (sys_properties) using this method as it causes a system-wide cache flush. Each flush can cause system degradation while the caches rebuild. If a value must be updated often, it should not be stored as a system property. In general, you should only place values in the sys_properties table that do not frequently change.
{#r_SGSYS-setProperty_S_S_S__table_s2v_hpx_fw__entry__3}

| Name | Type | Description |
|-|-|-|
| key | String | The key for the property to be set. |
| value | String | The value of the property to be set. |
| description | String | A description of the property. |
[Table 151. Parameters]

{#r_SGSYS-setProperty_S_S_S__table_s2v_hpx_fw} {#r_SGSYS-setProperty_S_S_S__table_t2v_hpx_fw__entry__2}

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

{#r_SGSYS-setProperty_S_S_S__table_t2v_hpx_fw}  
The following code example shows how to call this method.

    gs.setProperty("glide.foo","bar","foo");
    gs.info(gs.getProperty("glide.foo"));

Output:

    bar

## Scoped GlideSystem - setRedirect(Object o) {#ariaid-title78}

Sets the redirect URI for this transaction, which then determines the next page the
user will see.
{#r_ScopedGlideSystemSetRedirect_Object__table_tvp_kzm_1r__entry__3}

| Name | Type | Description |
|-|-|-|
| o | Object | URI object or URI string to set as the redirect |
[Table 153. Parameters]

{#r_ScopedGlideSystemSetRedirect_Object__table_tvp_kzm_1r} {#r_ScopedGlideSystemSetRedirect_Object__table_m15_bjr_2r__entry__2}

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

{#r_ScopedGlideSystemSetRedirect_Object__table_m15_bjr_2r}  

    gs.setRedirect("com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=d41ce5bac611227a0167f4bf8109bf70&sysparm_user=" 
    + current.sys_id + "&sysparm_email=" + current.email)

## Scoped GlideSystem - tableExists(String name) {#ariaid-title79}

Determines if a database table exists.
{#r_ScopedGlideSystemTableExists_String__table_oqg_q5h_1r__entry__3}

| Name | Type | Description |
|-|-|-|
| name | String | Name of the table to check for existence. |
[Table 155. Parameters]

{#r_ScopedGlideSystemTableExists_String__table_oqg_q5h_1r} {#r_ScopedGlideSystemTableExists_String__table_qqg_q5h_1r__entry__2}

| Type | Description |
|-|-|
| Boolean | True if the table exists. False if the table was not found. |
[Table 156. Returns]

{#r_ScopedGlideSystemTableExists_String__table_qqg_q5h_1r}  
This example shows checking whether the incident and foo tables exist in the ServiceNow instance.

    gs.info("Does the incident table exist? " + gs.tableExists("incident"));

    gs.info("Does the foo table exist? " + gs.tableExists("foo"));

Output:

    Does the incident table exist? true
    Does the foo table exist? false

## Scoped GlideSystem - urlEncode(String url) {#ariaid-title80}

Encodes non-ASCII characters, unsafe ASCII characters, and spaces so the returned
string can be used on the Internet. Uses UTF-8 encoding. Uses percent (%) encoding.
{#r_SGSYS-urlEncode_S__table_bgw_3ck_bx__entry__3}

| Name | Type | Description |
|-|-|-|
| url | String | The string to encode. |
[Table 157. Parameters]

{#r_SGSYS-urlEncode_S__table_bgw_3ck_bx} {#r_SGSYS-urlEncode_S__table_cgw_3ck_bx__entry__2}

| Type | Description |
|-|-|
| String | A string with non-ASCII characters, unsafe ASCII characters, and spaces encoded. |
[Table 158. Returns]

{#r_SGSYS-urlEncode_S__table_cgw_3ck_bx}

## Scoped GlideSystem - urlDecode(String url) {#ariaid-title81}

Replaces UTF-8 encoded characters with ASCII characters.
{#r_SGSYS-urlDecode_S__table_tp1_b2k_bx__entry__3}

| Name | Type | Description |
|-|-|-|
| url | String | UTF-8 percent (%) encoded characters. |
[Table 159. Parameters]

{#r_SGSYS-urlDecode_S__table_tp1_b2k_bx} {#r_SGSYS-urlDecode_S__table_up1_b2k_bx__entry__2}

| Type | Description |
|-|-|
| String | Encoded characters replaced with ASCII characters. |
[Table 160. Returns]

{#r_SGSYS-urlDecode_S__table_up1_b2k_bx}

## Scoped GlideSystem - warn(String message, Object parm1, Object parm2, Object parm3, Object
parm4, Object parm5) {#ariaid-title82}

Writes a warning message to the system log.
{#r_ScopedGlideSystemWarn_String_Object_Object_Object_Object_Object__table_o2s_wwh_1r__entry__3}

| Name | Type | Description |
|-|-|-|
| message | String | The log message with place holders for any variable arguments. |
| param1 | Object | (Optional) First variable argument. |
| param2 | Object | (Optional) Second variable argument. |
| param3 | Object | (Optional) Third variable argument. |
| param4 | Object | (Optional) Fourth variable argument. |
| param5 | Object | (Optional) Fifth variable argument. |
[Table 161. Parameters]

{#r_ScopedGlideSystemWarn_String_Object_Object_Object_Object_Object__table_o2s_wwh_1r} {#r_ScopedGlideSystemWarn_String_Object_Object_Object_Object_Object__table_lgd_2jr_2r__entry__2}

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

{#r_ScopedGlideSystemWarn_String_Object_Object_Object_Object_Object__table_lgd_2jr_2r}  

    gs.warn("This is a warning");
    var myFirstName = "Abel";
    var myLastName = "Tuter";
    gs.warn("This is a warning from {0}.{1}", myFirstName, myLastName);

Output:

    This is a warning
    This is a warning from Abel.Tuter

## Scoped GlideSystem - xmlToJSON(String xmlString) {#ariaid-title83}

Takes an XML string and returns a JSON object.
{#r_SGSYS-xmlToJSON_S__table_url_qn2_sv__entry__3}

| Name | Type | Description |
|-|-|-|
| xmlString | String | The XML string to be converted. |
[Table 163. Parameters]

{#r_SGSYS-xmlToJSON_S__table_url_qn2_sv} {#r_SGSYS-xmlToJSON_S__table_vrl_qn2_sv__entry__2}

| Type | Description |
|-|-|
| Object | A JSON object representing the XML string. Null if unable to process the XML string. |
[Table 164. Returns]

{#r_SGSYS-xmlToJSON_S__table_vrl_qn2_sv}  
The following code example shows how to call this method.

    var jsonObject = gs.xmlToJSON(xmlString);

## Scoped GlideSystem - yearsAgo(Number years) {#ariaid-title84}

Returns a date and time for a certain number of years ago in the user's session time zone as a UTC timestamp.
{#r_ScopedGlideSystemYearsAgo_N__table_o2l_23x_mt__entry__3}

| Name | Type | Description |
|-|-|-|
| years | Number | An integer number of years |
[Table 165. Parameters]

{#r_ScopedGlideSystemYearsAgo_N__table_o2l_23x_mt} {#r_ScopedGlideSystemYearsAgo_N__table_p2l_23x_mt__entry__2}

| Type | Description |
|-|-|
| String | UTC beginning of the year that is the specified number of years ago, in the format yyyy-mm-dd hh:mm:ss. |
[Table 166. Returns]

{#r_ScopedGlideSystemYearsAgo_N__table_p2l_23x_mt}

## Scoped GlideSystem - yesterday() {#ariaid-title85}

Returns yesterday's time (24 hours ago). Returned in the user's session time zone as a UTC timestamp.
{#SGSYS-yesterday__table_vwx_3wy_fz__entry__3}

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

{#SGSYS-yesterday__table_vwx_3wy_fz} {#SGSYS-yesterday__table_wwx_3wy_fz__entry__2}

| Type | Description |
|-|-|
| String | UTC for 24 hours ago, in the format yyyy-mm-dd hh:mm:ss |
[Table 168. Returns]

{#SGSYS-yesterday__table_wwx_3wy_fz}

