Service Portal and client scripts

  • Release version: Australia
  • Updated March 12, 2026
  • 2 minutes to read
  • Summarize
    Summarized using AI
    This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.

    Summary of Service Portal and client scripts

    Client scripts and catalog client scripts can be utilized within the Service Portal when the UI Type is set to Mobile / Service Portal or All. They are specifically designed for use with the Form widget and SC Catalog Item widget, rather than a widget client controller. It is crucial to ensure that only mobile APIs are used when flagging a script for Mobile/Service Portal compatibility.

    Show full answer Show less

    Key Features

    • Runtime Compatibility: You can create client scripts that behave differently based on whether they are running on desktop or mobile platforms by checking the runtime environment.
    • Unsupported Globals: Certain globals and APIs, such as $ and jQuery, are not available in client scripts used in the Service Portal, though widget client controllers can use Angular and jQuery.
    • Embedded Widgets: When using Macro variable types, you can embed widgets in catalog item forms and access relevant field objects and gform instances.
    • glist Global: Use the glist global to manage Glide list elements and list collector variables in the Service Portal.
    • gservicecatalog API: This API allows you to determine if a catalog item script is executed as part of an order guide.

    Key Outcomes

    By utilizing the appropriate client scripts in the Service Portal, customers can enhance user experience through tailored functionality for mobile and desktop interfaces. Understanding the limitations and capabilities of client scripts enables effective script deployment, ensuring compatibility with Service Portal requirements and enhancing overall service delivery.

    You can use client scripts and catalog client scripts in the Service Portal if the UI Type is set to Mobile / Service Portal or All. Client scripts and catalog client scripts are used with the Form widget and SC Catalog Item widget, as opposed to a widget client controller.

    Before flagging a script as Mobile/Service Portal or All, make sure that you are only using the mobile APIs. Setting a client script to Mobile does not ensure that it will work, it simply flags that the script should be attempted by the mobile app or the Service Portal. Many of your existing client scripts can be set to All as long as the API calls are supported by the mobile client scripting environment.

    The topics in this section require advanced coding knowledge and an understanding of Service Portal APIs.

    Checking desktop vs mobile runtime

    You might want to mark a client script compatible with both desktop and mobile, but include behavior that depends on the runtime. You can use this script:
      if (window === null)
        // Write your mobile compatible code here
      else
        // Write your desktop compatible code here

    Unsupported client scripting globals

    The following globals and APIs are unavailable in client scripts and catalog client scripts used in the Service Portal:

    • $
    • $$
    • $j
    • angular
    • control
    • document
    • jQuery
    • window
    Note:
    Widget client controllers are full Angular controllers and are not subject to the unsupported client script globals listed here. Use jQuery and Angular as needed.

    Embedded widgets & g_form

    When using the Service Catalog variable type Macro and Macro with Label, you can pick a widget to embed in a catalog item form. Within the client controller for the embedded widget you can access the field object and catalog item g_form instance using:

    • $scope.page.field
    • $scope.page.g_form()

    Client scripts used with Service Portal

    The g_list global helps you set the filter of a Glide list element or a list collector variable. Use this API in place of the g_filter API on desktop client scripts.
    function onLoad() {
      var myListCollector = g_list.get("my_list_collector");
      myListCollector.reset();
      myListCollector.setQuery("active=true^category=8c7b22230b402200b0b02c6317673a62");
      myListCollector.addItem('3a700d39af5f4fc0aab978df90f4c692', 'Power Supply');
      myListCollector.addItem('1cb93419a3a248318da8f814140b42f6', 'Backpack');
    }
    g_service_catalog is only available in Service Portal service catalog item scripts. Use this API to know if your catalog item script is run as part of an order guide or on its own.
    function onLoad() {
      if (window) // if CMS, don't run this
       return;
    
       // g_service_catalog api for Service Portal and Mobile
       var isOrderGuide = g_service_catalog.isOrderGuide();
       g_form.setValue("is_order_guide", isOrderGuide ? "Yes!" : "Nope :(");
    }