Product documentation Docs
    • English
    • Deutsch
    • 日本語
    • 한국어
    • Français
  • More Sites
    • Now Community
    • Developer Site
    • Knowledge Base
    • Product Information
    • ServiceNow.com
    • Training
    • Customer Success Center
    • ServiceNow Support Videos
  • Log in

Product documentation

  • Home
How search works:
  • Punctuation and capital letters are ignored
  • Special characters like underscores (_) are removed
  • Known synonyms are applied
  • The most relevant topics (based on weighting and matching to search terms) are listed first in search results
Topics are ranked in search results by how closely they match your search terms
  • A match on the entire phrase you typed
  • A match on part of the phrase you typed
  • A match on ALL of the terms in the phrase you typed
  • A match on ANY of the terms in the phrase you typed

Note: Matches in titles are always highly ranked.

  • Release version
    Table of Contents
    • Now Platform capabilities
Table of Contents
Choose your release version
    Home New York Now Platform Capabilities Now Platform capabilities Service Portal Supported features in Service Portal Supported client script types and APIs

    Supported client script types and APIs

    • Save as PDF Selected topic Topic & subtopics All topics in contents
    • Unsubscribe Log in to subscribe to topics and get notified when content changes.
    • Share this page

    Supported client script types and APIs

    Some client scripts are not supported in Service Portal. Others must have a UI type set to All or Mobile / Service Portal. If using a client script in the Service Portal, only client-side APIs supported in a mobile environment can be used.

    Client script support in Service Portal

    Client script Description
    Catalog client scripts Service Portal requires that the UI Type field be set to All or Mobile / Service Portal. Client Scripts marked as Desktop rely on legacy APIs that are not supported in Service Portal. Before flagging a script as Mobile / Service Portal or All, make sure you are only using supported client-side APIs.
    Validation scripts

    Service Portal requires that the UI Type field be set to All or Mobile / Service Portal. Client Scripts marked as Desktop rely on legacy APIs that are not supported in Service Portal. Before flagging a script as Mobile / Service Portal or All, make sure you are only using supported client-side APIs.

    Validate user input in a specific field type using a validation script. In new instances, Service Portal includes XML, Script, Script (Plain), Email, and Version validation scripts by default. If upgrading from a previous release, the Mobile and Service Portal version is not active by default. You must activate the Mobile and Service Portal version of the validation script to validate user input in the Service Portal. See Activate Service Portal validation scripts.

    Note: To call a UI script within a Validation script, use the g_ui_scripts global object. For more information, see GlideUIScripts. Verify that the UI script has the Global field set to false and UI Type set to Mobile / Service Portal or All.
    UI scripts Service Portal requires that the UI Type field be set to All or Mobile / Service Portal. Client Scripts marked as Desktop rely on legacy APIs that are not supported in Service Portal. Before flagging a script as Mobile / Service Portal or All, make sure you are only using supported client-side APIs.
    UI Actions All server-side UI actions are supported in Service Portal, although setRedirectURL() operations are ignored because Service Portal forms handle redirection in a different way than the platform.

    The form widget ignores any UI Actions marked as Client.

    UI Policies Supported, although you should use only declarative UI Policies. Avoid scripting unless the outcome cannot be achieved through the condition builder.
    UI Macros Not supported as UI macros use Jelly.
    Formatters Not supported as formatters use Jelly.

    Supported client-side APIs

    Supported client scripting APIs for use in onLoad, onChange, and onSubmit client scripts.

    For detailed class and method information, see the API reference.

    Class Available methods
    g_form
    • addDecoration(fieldName, icon, title)
    • addErrorMessage(message)
    • addInfoMessage(message)
    • addOption(fieldName, value, label, index)
    • clearOptions(fieldName)
    • getActionName()
    • getBooleanValue(fieldName)
    • getDecimalValue(fieldName)
    • getEncodedRecord()
    • getFieldNames()
    • getIntValue(fieldName)
    • getLabel(fieldName)
    • getReference(fieldName, callback)
    • getRelatedListNames()
    • getSectionNames()
    • getSysId()
    • getTableName()
    • getValue(fieldName)
    • hasField(fieldName)
    • hideAllFieldMsgs(type: "info | error")
    • hideErrorBox(fieldName)
    • hideFieldMsg(fieldName, clearAll)
    • hideRelatedList(listTableName)
    • hideRelatedLists()
    • isMandatory(fieldName)
    • isNewRecord()
    • isReadOnly(fieldName)
    • isVisible(fieldName)
    • removeDecoration(fieldName, icon, title)
    • removeOption(fieldName, value)
    • save()
    • serialize(onlyDirtyFields)
    • setFieldPlaceholder(fieldName, placeholder)
    • setLabel(fieldName, label)
    • setMandatory(fieldName, isMandatory)
    • setReadOnly(fieldName, isReadOnly)
    • setSectionDisplay(sectionName, isVisible)
    • setValue(fieldName, value, displayValue)
    • setVisible(fieldName, isVisible)
    • showErrorBox(fieldName, message, scrollForm)
    • showFieldMsg(fieldName, message, type: "info | error", scrollForm)
    • showRelatedList(relatedTableName)
    • showRelatedLists()
    • submit(submitActionName)
    Note: Using the variables.var_name notation with the g_form API is not supported in Service Portal. g_form as a global object cannot be used in a widget client controller or in a UI script.
    g_list
    • get(fieldName)
    • addItem(value, displayValue)
    • removeItem(value)
    • reset()
    • setQuery(queryString)
    • setDefaultOperator(operator)
    • getDefaultOperator()
    g_service_catalog

    isOrderGuide()

    GlideAjax
    • addParam (name, value)
    • getParam (name)
    • getXML(callback)
    • getXMLAnswer(callback)
    • getJSON(callback)
    • setErrorCallback(errorCallback)
    • getURL()
    • getParams()
    • execute()
    • successCalback(data, status, xhr)
    • errorCallback(xhr)
    • setScope(scope)
    Note: Because the mobile platform does not allow synchronous GlideAjax calls, the getXMLWait() method in a GlideAjax call does not work in the Service Portal. Instead, use one of the asynchronous calls such as getXML(Function callback) or getXMLAnswer(Function callback).
    Note: GlideAjax cannot be used in a widget client controller.
    GlideRecord
    • addQuery(encodedQuery)
    • addQuery(fieldName, operator, value)
    • getEncodedQuery()
    • get(id)
    • getTableName()
    • hasNext()
    • insert(callback)
    • gotoTop()
    • next()
    • loadRow(rowObj)
    • getValue(fieldName)
    • setValue(fieldName, value)
    • isDotWalkField(fieldName)
    • addOrderBy(fieldName)
    • setDisplayFields(fieldNames)
    • query(callback)
    • setRows(rowsArray)
    • setTableName(tableName)
    • setLimit(maxInt)
    • getLimit()
    i18NV3

    getMessage(String messageKey, Function callback)

    Tags:

    Feedback
    On this page

    Previous topic

    Next topic

    • Contact Us
    • Careers
    • Terms of Use
    • Privacy Statement
    • Sitemap
    • © ServiceNow. All rights reserved.

    Release version
    Choose your release version

      Supported client script types and APIs

      • Save as PDF Selected topic Topic & subtopics All topics in contents
      • Unsubscribe Log in to subscribe to topics and get notified when content changes.
      • Share this page

      Supported client script types and APIs

      Some client scripts are not supported in Service Portal. Others must have a UI type set to All or Mobile / Service Portal. If using a client script in the Service Portal, only client-side APIs supported in a mobile environment can be used.

      Client script support in Service Portal

      Client script Description
      Catalog client scripts Service Portal requires that the UI Type field be set to All or Mobile / Service Portal. Client Scripts marked as Desktop rely on legacy APIs that are not supported in Service Portal. Before flagging a script as Mobile / Service Portal or All, make sure you are only using supported client-side APIs.
      Validation scripts

      Service Portal requires that the UI Type field be set to All or Mobile / Service Portal. Client Scripts marked as Desktop rely on legacy APIs that are not supported in Service Portal. Before flagging a script as Mobile / Service Portal or All, make sure you are only using supported client-side APIs.

      Validate user input in a specific field type using a validation script. In new instances, Service Portal includes XML, Script, Script (Plain), Email, and Version validation scripts by default. If upgrading from a previous release, the Mobile and Service Portal version is not active by default. You must activate the Mobile and Service Portal version of the validation script to validate user input in the Service Portal. See Activate Service Portal validation scripts.

      Note: To call a UI script within a Validation script, use the g_ui_scripts global object. For more information, see GlideUIScripts. Verify that the UI script has the Global field set to false and UI Type set to Mobile / Service Portal or All.
      UI scripts Service Portal requires that the UI Type field be set to All or Mobile / Service Portal. Client Scripts marked as Desktop rely on legacy APIs that are not supported in Service Portal. Before flagging a script as Mobile / Service Portal or All, make sure you are only using supported client-side APIs.
      UI Actions All server-side UI actions are supported in Service Portal, although setRedirectURL() operations are ignored because Service Portal forms handle redirection in a different way than the platform.

      The form widget ignores any UI Actions marked as Client.

      UI Policies Supported, although you should use only declarative UI Policies. Avoid scripting unless the outcome cannot be achieved through the condition builder.
      UI Macros Not supported as UI macros use Jelly.
      Formatters Not supported as formatters use Jelly.

      Supported client-side APIs

      Supported client scripting APIs for use in onLoad, onChange, and onSubmit client scripts.

      For detailed class and method information, see the API reference.

      Class Available methods
      g_form
      • addDecoration(fieldName, icon, title)
      • addErrorMessage(message)
      • addInfoMessage(message)
      • addOption(fieldName, value, label, index)
      • clearOptions(fieldName)
      • getActionName()
      • getBooleanValue(fieldName)
      • getDecimalValue(fieldName)
      • getEncodedRecord()
      • getFieldNames()
      • getIntValue(fieldName)
      • getLabel(fieldName)
      • getReference(fieldName, callback)
      • getRelatedListNames()
      • getSectionNames()
      • getSysId()
      • getTableName()
      • getValue(fieldName)
      • hasField(fieldName)
      • hideAllFieldMsgs(type: "info | error")
      • hideErrorBox(fieldName)
      • hideFieldMsg(fieldName, clearAll)
      • hideRelatedList(listTableName)
      • hideRelatedLists()
      • isMandatory(fieldName)
      • isNewRecord()
      • isReadOnly(fieldName)
      • isVisible(fieldName)
      • removeDecoration(fieldName, icon, title)
      • removeOption(fieldName, value)
      • save()
      • serialize(onlyDirtyFields)
      • setFieldPlaceholder(fieldName, placeholder)
      • setLabel(fieldName, label)
      • setMandatory(fieldName, isMandatory)
      • setReadOnly(fieldName, isReadOnly)
      • setSectionDisplay(sectionName, isVisible)
      • setValue(fieldName, value, displayValue)
      • setVisible(fieldName, isVisible)
      • showErrorBox(fieldName, message, scrollForm)
      • showFieldMsg(fieldName, message, type: "info | error", scrollForm)
      • showRelatedList(relatedTableName)
      • showRelatedLists()
      • submit(submitActionName)
      Note: Using the variables.var_name notation with the g_form API is not supported in Service Portal. g_form as a global object cannot be used in a widget client controller or in a UI script.
      g_list
      • get(fieldName)
      • addItem(value, displayValue)
      • removeItem(value)
      • reset()
      • setQuery(queryString)
      • setDefaultOperator(operator)
      • getDefaultOperator()
      g_service_catalog

      isOrderGuide()

      GlideAjax
      • addParam (name, value)
      • getParam (name)
      • getXML(callback)
      • getXMLAnswer(callback)
      • getJSON(callback)
      • setErrorCallback(errorCallback)
      • getURL()
      • getParams()
      • execute()
      • successCalback(data, status, xhr)
      • errorCallback(xhr)
      • setScope(scope)
      Note: Because the mobile platform does not allow synchronous GlideAjax calls, the getXMLWait() method in a GlideAjax call does not work in the Service Portal. Instead, use one of the asynchronous calls such as getXML(Function callback) or getXMLAnswer(Function callback).
      Note: GlideAjax cannot be used in a widget client controller.
      GlideRecord
      • addQuery(encodedQuery)
      • addQuery(fieldName, operator, value)
      • getEncodedQuery()
      • get(id)
      • getTableName()
      • hasNext()
      • insert(callback)
      • gotoTop()
      • next()
      • loadRow(rowObj)
      • getValue(fieldName)
      • setValue(fieldName, value)
      • isDotWalkField(fieldName)
      • addOrderBy(fieldName)
      • setDisplayFields(fieldNames)
      • query(callback)
      • setRows(rowsArray)
      • setTableName(tableName)
      • setLimit(maxInt)
      • getLimit()
      i18NV3

      getMessage(String messageKey, Function callback)

      Tags:

      Feedback

          Share this page

          Got it! Feel free to add a comment
          To share your product suggestions, visit the Idea Portal.
          Please let us know how to improve this content

          Check any that apply

          To share your product suggestions, visit the Idea Portal.
          Confirm

          We were unable to find "Coaching" in Jakarta. Would you like to search instead?

          No Yes
          • Contact Us
          • Careers
          • Terms of Use
          • Privacy Statement
          • Sitemap
          • © ServiceNow. All rights reserved.

          Subscribe Subscribed Unsubscribe Last updated: Tags: January February March April May June July August September October November December No Results Found Versions Search preferences successfully updated My release version successfully updated My release version successfully deleted An error has occurred. Please try again later. You have been unsubscribed from all topics. You are now subscribed to and will receive notifications if any changes are made to this page. You have been unsubscribed from this content Thank you for your feedback. Form temporarily unavailable. Please try again or contact  docfeedback@servicenow.com  to submit your comments. The topic you requested does not exist in the release. You were redirected to a related topic instead. The available release versions for this topic are listed There is no specific version for this documentation. Explore products Click to go to the page. Release notes and upgrades Click to open the dropdown menu. Delete Remove No selected version Reset This field is required You are already subscribed to this topic Attach screenshot The file you uploaded exceeds the allowed file size of 20MB. Please try again with a smaller file. Please complete the reCAPTCHA step to attach a screenshot
          Log in to personalize your search results and subscribe to topics
          No, thanks Login