JavaScript APIs supported by guarded script

  • Release version: Zurich
  • Updated May 5, 2026
  • 3 minutes to read
  • Review the JavaScript APIs that guarded script supports to help you analyze scripts in the Incompatible Guarded Scripts list and either rewrite them or create an exemption for them.

    The guarded script evaluator permits the following methods from the ServiceNow server-side JavaScript APIs and the built-in JavaScript APIs. The guarded script evaluator handles scripts that call unsupported APIs differently depending on the transaction type and instance configuration. For more information, see Guarded script evaluator.

    ServiceNow JavaScript APIs supported by guarded script

    Guarded script permits calling the following methods from server-side JavaScript APIs in untrusted scripts. For more information about server APIs, see Server API reference.

    Table 1. Allowed ServiceNow JavaScript methods
    Class Method
    GlideSystem (gs)
    • beginningOfCurrentHour()
    • beginningOfCurrentMinute()
    • beginningOfDay()
    • beginningOfLast120Days()
    • beginningOfLast12Months()
    • beginningOfLast15Minutes()
    • beginningOfLast2Hours()
    • beginningOfLast2Quarters()
    • beginningOfLast2Years()
    • beginningOfLast30Days()
    • beginningOfLast30Minutes()
    • beginningOfLast3Months()
    • beginningOfLast45Minutes()
    • beginningOfLast60Days()
    • beginningOfLast6Months()
    • beginningOfLast7Days()
    • beginningOfLast90Days()
    • beginningOfLast9Months()
    • beginningOfLastHour()
    • beginningOfLastMinute()
    • beginningOfLastMonth()
    • beginningOfLastQuarter()
    • beginningOfLastSchedulePeriod()
    • beginningOfLastWeek()
    • beginningOfLastYear()
    • beginningOfMonth()
    • beginningOfNext2Quarters()
    • beginningOfNextMonth()
    • beginningOfNextQuarter()
    • beginningOfNextSchedulePeriod()
    • beginningOfNextWeek()
    • beginningOfNextYear()
    • beginningOfOneYearAgo()
    • beginningOfSchedulePeriodsAgo()
    • beginningOfThisMonth()
    • beginningOfThisQuarter()
    • beginningOfThisSchedulePeriod()
    • beginningOfThisWeek()
    • beginningOfThisYear()
    • beginningOfToday()
    • beginningOfTomorrow()
    • beginningOfWeek()
    • beginningOfYear()
    • beginningOfYesterday()
    • calDateDiff()
    • dateAdd()
    • dateDiff()
    • dateGenerate()
    • datePart()
    • daysAgo()
    • daysAgoEnd()
    • daysAgoLocal()
    • daysAgoStart()
    • endOfCurrentHour()
    • endOfCurrentMinute()
    • endOfDay()
    • endOfLast120Days()
    • endOfLast12Months()
    • endOfLast15Minutes()
    • endOfLast2Hours()
    • endOfLast2Quarters()
    • endOfLast2Years()
    • endOfLast30Days()
    • endOfLast30Minutes()
    • endOfLast3Months()
    • endOfLast45Minutes()
    • endOfLast60Days()
    • endOfLast6Months()
    • endOfLast7Days()
    • endOfLast90Days()
    • endOfLast9Months()
    • endOfLastHour()
    • endOfLastMinute()
    • endOfLastMonth()
    • endOfLastQuarter()
    • endOfLastSchedulePeriod()
    • endOfLastWeek()
    • endOfLastYear()
    • endOfMonth()
    • endOfNext2Quarters()
    • endOfNextMonth()
    • endOfNextQuarter()
    • endOfNextSchedulePeriod()
    • endOfNextWeek()
    • endOfNextYear()
    • endOfOneYearAgo()
    • endOfSchedulePeriodsAgo()
    • endOfThisMonth()
    • endOfThisQuarter()
    • endOfThisSchedulePeriod()
    • endOfThisWeek()
    • endOfThisYear()
    • endOfToday()
    • endOfTomorrow()
    • endOfWeek()
    • endOfYear()
    • endOfYesterday()
    • generateGUID()
    • getCurrentScopeName()
    • getDurationDate()
    • getMessage()
    • getPreference()
    • getUser()
    • getUserDisplayName()
    • getUserID()
    • getUserName()
    • hasRole()
    • hoursAgo()
    • hoursAgoEnd()
    • hoursAgoLocal()
    • hoursAgoStart()
    • isFirstDayOfMonth()
    • isFirstDayOfWeek()
    • isFirstDayOfYear()
    • isInteractive()
    • isLastDayOfMonth()
    • isLastDayOfWeek()
    • isLastDayOfYear()
    • isLoggedIn()
    • lastWeek()
    • minutesAgo()
    • minutesAgoEnd()
    • minutesAgoStart()
    • monthsAgo()
    • monthsAgoEnd()
    • monthsAgoStart()
    • nil()
    • now()
    • nowDateTime()
    • nowGlideDateTime()
    • nowNoTZ()
    • quartersAgo()
    • quartersAgoEnd()
    • quartersAgoStart()
    • user()
    • userID()
    • user_id()
    • yearsAgo()
    • yesterday()
    GlideUser
    • getCompanyID()
    • getCompanyRecord()
    • getCountry()
    • getDateFormat()
    • getDateFormatEx()
    • getDateTimeFormat()
    • getDepartmentID()
    • getDisplayName()
    • getDomainDisplayValue()
    • getDomainID()
    • getEmail()
    • getFirstName()
    • getFullName()
    • getLanguage()
    • getLastName()
    • getLocation()
    • getManagedGroups()
    • getManagerID()
    • getManagerName()
    • getMobileNumber()
    • getMyExplicitGroups()
    • getMyGroups()
    • getMyGroupsExcludeAdmin()
    • getTZ()
    • getTimeFormat()
    • getTimeFormatEx()
    • getTimeZoneLabel()
    • getTimeZoneLabelLang()
    • getTitle()
    • getUserRoles()
    • isExplicitMemberOf()
    • isMemberOf()
    GlideDate
    • getByFormat()
    • getDayOfMonthNoTZ()
    • getDisplayValue()
    • getDisplayValueEx()
    • getDisplayValueInternal()
    • getDisplayValueLang()
    • getMonthNoTZ()
    • parseDate()
    • setDisplayValue()
    • setDisplayValueEx()
    • setDisplayValueLang()
    • setValue()
    GlideDateTime
    • add()
    • addDays()
    • addDaysLocalTime()
    • addDaysUTC()
    • addMonths()
    • addMonthsLocalTime()
    • addMonthsUTC()
    • addSeconds()
    • addWeeks()
    • addYears()
    • compareTo()
    • getDate()
    • getDayOfMonth()
    • getDayOfMonthLocalTime()
    • getDayOfMonthUTC()
    • getDayOfWeek()
    • getDayOfWeekLocalTime()
    • getDayOfWeekUTC()
    • getDaysInMonth()
    • getDaysInMonthLocalTime()
    • getDaysInMonthUTC()
    • getDisplayValue()
    • getDisplayValueEx()
    • getDisplayValueInternal()
    • getDisplayValueLang()
    • getLocalDate()
    • getLocalTime()
    • getMonth()
    • getMonthLocalTime()
    • getMonthUTC()
    • getNumericValue()
    • getTZOffset()
    • getTime()
    • getUserTimeZone()
    • getValue()
    • getWeekOfYearLocalTime()
    • getWeekOfYearUTC()
    • getYear()
    • getYearLocalTime()
    • getYearUTC()
    • isDST()
    • onOrAfter()
    • onOrBefore()
    • setDayOfMonthUTC()
    • setDisplayValue()
    • setDisplayValueEx()
    • setDisplayValueLang()
    • setMonth()
    • setNumericValue()
    • setTZ()
    • setTimeZone()
    • setValue()
    • setValueUTC()
    • subtract()
    • toString()
    GlideTime
    • getDisplayValue()
    • setValue()
    GlideRecord
    • getDisplayValue()
    • getUniqueValue()
    • getValue()
    • isValid()
    • isValidRecord()
    GlideBusinessCalendarUtil
    • getCalendarEnd()
    • getCalendarFilterOptions()
    • getCalendarSpanBounds()
    • getCalendarStart()
    • getCalendars()
    • isLegacySchedule()
    GlideApplicationProperty getValue()
    GlidePluginManager isActive()
    GlideLocale get()
    GlideSessionDebug
    • disable()
    • enable()
    GlideDomainSupport getCurrentDomainValueOrGlobal()
    GlideAccessibility isEnabled()
    GlideJSUtil
    • nil()
    • notNil()
    GlideNumberManager getNextObjNumberPadded()
    TableUtils getAllExtensions()
    GlideListFilter
    • getItilDefaultGroupTypes()
    • getNonItilDefaultGroupTypes()
    GlideEmailWatermark optionallyRandomize()
    GlideCounter next()
    GlideProperties get()
    GlideTSDebug enable()
    DashboardFiltersParser
    • getBookmarked()
    • getCertified()
    • getCreatedByMe()
    • getDashboardsWithCategories()
    • getRecent()
    • getSharedWithMe()

    JavaScript built-in APIs supported by guarded script

    Guarded script also permits calling the following methods on JavaScript built-in objects in untrusted scripts.

    Table 2. Allowed JavaScript built-in methods
    Object Method
    Array
    Static methods:
    • isArray()
    • of()
    Instance methods:
    • concat()
    • entries()
    • flat()
    • includes()
    • indexOf()
    • join()
    • keys()
    • lastIndexOf()
    • length
    • slice()
    • toString()
    • values()
    Object
    Static methods:
    • entries()
    • getOwnPropertyDescriptor()
    • getOwnPropertyNames()
    • is()
    • isExtensible()
    • isFrozen()
    • isSealed()
    • keys()
    • values()
    Instance methods:
    • hasOwnProperty()
    • isPrototypeOf()
    • propertyIsEnumerable()
    • toLocaleString()
    • toString()
    • valueOf()
    String
    Static methods:
    • fromCharCode()
    • fromCodePoint()
    Instance methods:
    • at()
    • charAt()
    • charCodeAt()
    • codePointAt()
    • concat()
    • endsWith()
    • includes()
    • indexOf()
    • lastIndexOf()
    • length
    • normalize()
    • replace()
    • replaceAll()
    • slice()
    • split()
    • startsWith()
    • substr()
    • substring()
    • toLocaleLowerCase()
    • toLocaleUpperCase()
    • toLowerCase()
    • toString()
    • toUpperCase()
    • trim()
    • trimEnd()
    • trimStart()
    • valueOf()
    Number (constructor)
    Static methods:
    • isFinite()
    • isInteger()
    • isNaN()
    • isSafeInteger()
    • parseFloat()
    • parseInt()
    Instance methods:
    • toExponential()
    • toFixed()
    • toLocaleString()
    • toPrecision()
    • toString()
    • valueOf()
    Boolean (constructor)
    Instance methods:
    • toString()
    • valueOf()
    Date (constructor)
    Static methods:
    • now()
    • parse()
    • UTC()
    Instance methods:
    • getDate()
    • getDay()
    • getFullYear()
    • getHours()
    • getMilliseconds()
    • getMinutes()
    • getMonth()
    • getSeconds()
    • getTime()
    • getTimezoneOffset()
    • getUTCDate()
    • getUTCDay()
    • getUTCFullYear()
    • getUTCHours()
    • getUTCMilliseconds()
    • getUTCMinutes()
    • getUTCMonth()
    • getUTCSeconds()
    • toDateString()
    • toGMTString()
    • toISOString()
    • toJSON()
    • toLocaleDateString()
    • toLocaleString()
    • toLocaleTimeString()
    • toString()
    • toTimeString()
    • toUTCString()
    • valueOf()
    Math
    Static methods:
    • abs()
    • acos()
    • asin()
    • atan()
    • atan2()
    • ceil()
    • cos()
    • exp()
    • floor()
    • log()
    • max()
    • min()
    • pow()
    • random()
    • round()
    • sin()
    • sqrt()
    • tan()
    JSON
    Static methods:
    • parse()
    • stringify()