---
sourceDocument: Brazil ServiceNow AI Platform user interface
sourceDocumentLink: https://www.servicenow.com/docs/r/platform-user-interface

 Release :

    - brazil

ft:locale :

    - en-US

ft:publication_title :

    - Brazil ServiceNow AI Platform user interface

ft:clusterId :

    - platux

bundleId :

    - platux

workflow :

    - Platform


---

# Developing custom widgets

# Developing custom widgets {#ariaid-title1}

Release version: Brazil  
Updated September 10, 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 3 minutes to read
Summarize  
![AI sparkle icon](https://servicenow.com/docs/portal-asset/ai-sparkle-icon) 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 Developing custom widgets

Develop custom widgets for ServiceNow portals using AngularJS, Bootstrap, and the ServiceNow API.
Widgets enable dynamic, interactive components on Service Portal pages by combining HTML templates, client and server scripts, and optional AngularJS features.
Developing widgets requires experience with ServiceNow APIs for server-side data operations and AngularJS for client-side data binding and user interaction.
Show full answer Show less  

## Key Components of a Widget

* **HTML Template (mandatory):** Uses AngularJS to render dynamic views, bind variables, and gather user input.
* **Client Script (mandatory):** Implements the client controller using ServiceNow API and AngularJS to process data, handle user input, and communicate with server scripts.
* **Server Script (mandatory):** Manages server-side logic such as initializing widget state, querying records, and sending data to the client.
* **Link Function (optional):** Manipulates the DOM directly using AngularJS.
* **Option Schema (optional):** Defines configurable parameters that allow Service Portal admins to customize widget instances.
* **Angular Providers (optional):** Create reusable services to share state and behaviors across multiple widgets, improving performance and maintainability.
* **Dependencies (optional):** Link external JavaScript or CSS files to extend widget functionality.

## Global Objects and Data Flow

Widgets utilize three global objects in the server script: **input** (data from the client), **options** (widget configuration), and **data** (data sent to the client). The client controller accesses server data via `c.data` and uses `server.update()` to post changes back to the server. The `c.options` object provides read-only access to widget invocation parameters.

## Development Tools and Best Practices

* **Widget Editor:** A dedicated IDE-like environment for creating and editing widgets with real-time preview.
* **ECMAScript 2021 Support:** Server scripts can use modern JavaScript syntax by enabling ES12 mode.
* **Reuse and Extend:** Clone existing widgets to accelerate development or create new ones from scratch.
* **Widget Option Schema:** Define parameters for flexible widget configuration per instance.
* **Angular Providers:** Use to maintain state and share components across widgets for better performance.

## Additional Capabilities

* **Embedded Widgets:** Embed widgets within other widget scripts or templates for modular design.
* **Widget Dependencies:** Link third-party libraries or stylesheets as dependencies.
* **Internationalization:** Use `${}` or `gs.getMessage()` syntax to tag strings for translation and localization.
* **Replacing UI Macros:** Widgets can replace Service Catalog UI Macros, supporting reusable code and variable access.

## Troubleshooting and Integration

Use provided troubleshooting tools to diagnose and fix custom widget issues. Additionally, leverage embeddables---UI Builder components that can be integrated across Service Portal and external websites---to reduce development effort and enhance integration flexibility.  
Develop custom widgets for portals using AngularJS, Bootstrap, and the ServiceNow API.

## Before you begin {#widget-dev-guide__section_xrx_qf2_kz}

To develop widgets, you need ServiceNow API experience to:

* Run record queries on the server.
* Create and update records.
{#widget-dev-guide__ul_bs4_rch_j1b}  
You need AngularJS experience to:

* Bind variables to client controllers.
* Access server objects in a widget.
* Gather user input.
{#widget-dev-guide__ul_hmf_5ch_j1b}

Optionally, you can build on the Bootstrap template by accessing Bootstrap components.

## Parts of a widget {#widget-dev-guide__section_gpd_lkw_h1b}

Like Angular directives, widgets execute a specified behavior within a Service Portal page. A widget includes
mandatory and optional scripting components.  

HTML template

:   A mandatory widget component.

    The HTML template requires knowledge of AngularJS to display and gather data. Use the HTML
    template to:  
    * Render the dynamic view that a user sees in the browser using information from the model and controller.
    * Bind client script variables to your markup.
    * Gather data from the end user.
    {#widget-dev-guide__ul_chb_mdh_j1b}

Client script

:   A mandatory widget component.

    A client script requires knowledge of both the ServiceNow API and AngularJS to create a
    client controller. Use the client script to:  
    * Map server data from JavaScript and JSON objects to client objects.
    * Process data before rendering it.
    * Pass data to the HTML template.
    * Pass user input and data back to the server for processing.
    {#widget-dev-guide__ul_elh_d2h_j1b}

Server script

:   A mandatory widget component.

    A server script requires knowledge of the ServiceNow API to work with record data.
    Use the server script to:  
    * Set the initial state of the widget.
    * Send record data to the widget client script using the data variable.
    * Run server-side queries.
    {#widget-dev-guide__ul_n5p_42h_j1b}

Link function

:   An optional widget component.

    The link function requires knowledge of AngularJS. Use a link function to directly
    manipulate the DOM.

Option schema

:   An optional widget component.

    Allows a Service Portal admin to
    configure a widget. Use the option schema to:  
    * Specify the parameters for a widget.
    * Allow admin users to define instance options for a widget instance.
    * Develop flexible, reusable widgets.
    {#widget-dev-guide__ul_cmx_w3h_j1b}

Angular Providers

:   An optional widget component.

    Angular Providers require knowledge of AngularJS. Use Angular Providers to:  
    * Keep widgets in sync when changing records or filters.
    * Share context between widgets.
    * Maintain and persist state.
    * Create reusable behaviors and UI components and inject them into multiple widgets.
    {#widget-dev-guide__ul_mm2_2zq_yz}

Dependencies

:   An optional widget component.

    A widget dependency is an external resource used by your widget such as JavaScript or CSS
    files.

## Global objects in widgets {#widget-dev-guide__section_rsq_g1h_j1b}

When a widget begins to render for the first time on a page, the server script executes first
and accesses three global objects: input, options,
and data. Because the input variable is a data
object sent from the client script, this variable is undefined when first initialized.

When a widget is first instantiated, the server script:  
1. Initializes an empty data object.
2. Initializes the input object with any data sent from the client controller, or the options object with any data used to initialize the widget.
3. Sends the data object to the client controller as JSON.
{#widget-dev-guide__ol_sh3_btw_xz}

The client script:  
1. Accesses the server data object using `c.data`.

   Note:  
   By default, widgets use the c variable to represent the controller instance using `controller as` syntax. You can change this variable when creating or cloning widgets.
2. Uses `server.update()` to post changes to the data model. This method
   updates the server script using the input object.

   Note:  
   After calling `server.update()`, the client script data object is automatically overwritten by the server script data object.
3. Uses `c.options` to access the values used to invoke the widget on the server. This object is read-only.
{#widget-dev-guide__ol_mjs_jtw_xz}

## Using the Widget Editor {#widget-dev-guide__section_dsy_kch_j1b}

When you create a widget, a record is created in the sp_widget table. However, you can use the Widget Editor in Service Portal Configuration as your scripting environment. The Widget Editor is a full page application similar to an IDE. You can show the parts of the widget you want to edit and hide the rest, while
previewing your changes in real time.  
Note:  
For server-side scripts, you can turn on using the ECMAScript 2021 (ES12) JavaScript mode if your application uses ES5 Standards mode or Compatibility mode. Scripts in applications with the JavaScript mode set to ECMAScript 2021 (ES12) use ECMAScript 2021 (ES12) by default. For more information, see [Turn on ECMAScript 2021 (ES12) mode for a script](https://www.servicenow.com/docs/access?context=set-es12-mode-scripts&version=brazil&pubname=brazil-api-reference&ft:locale=en-US).

<br />

* **[General guidelines for developing widgets](https://www.servicenow.com/docs/~l54cvkMBBNFja73dgOpXA)**   
  When developing custom widgets, keep these general guidelines in mind for optimal performance, scalable development, and a good user experience.
* **[Tutorial: Build a custom widget](https://www.servicenow.com/docs/clAD3xucJ_CrkwSXtjcD6g#adv-widget-tutorial)**   
  Follow this tutorial to build a custom widget that displays Service Catalog items. Use this tutorial as a model to help you understand the advanced scripting power of the Service Portal.
* **[Clone a widget](https://www.servicenow.com/docs/kWVflT2Sy9FW6mf5RMGRsA)**   
  Take advantage of existing code by cloning and editing an existing widget.
* **[Create a new widget](https://www.servicenow.com/docs/ym1idCjTuDnEyXsXMZtTAQ)**   
  Create a new widget to build a custom widget from scratch.
* **[Widget option schema](https://www.servicenow.com/docs/k8fdOlcy~eGj1dQTjScfSQ#c_WidgetInstanceOptions)**   
  Widget instances allow users to uniquely configure each widget they add to a page. Use the option schema to define the parameters for your widget.
* **[Widget API reference](https://www.servicenow.com/docs/vSKi7I8LDDzfrB0ws2E3Kg#widget-api-reference)**   
  Service Portal includes client and server side APIs to use in widget client and server scripts.
* **[Reuse components with Angular Providers](https://www.servicenow.com/docs/gZyXV4Kam4xS6mFhj3EPxA)**   
  Angular Providers are reusable components that can be injected into multiple widgets. To ensure quick loading widgets and a high performing portal, create Angular Providers instead of overloading your client controllers with persistent data and additional logic. With Angular Providers, you can maintain data for the lifetime of your Service Portal and reuse components and data objects across multiple widgets.
* **[Embedded widgets](https://www.servicenow.com/docs/y~dHELGEXtGG19gQmSgGzw#c_NestedWidgets)**   
  Embed a widget in the HTML template, server script, or client script.
* **[Create a widget dependency](https://www.servicenow.com/docs/lcN1qV1TKE0GLR0xCXvLkQ)**   
  In Service Portal, you can link JavaScript and CSS files to widgets to create dependencies between widgets and third-party libraries, external style sheets, and angular modules.
* **[Internationalize a widget](https://www.servicenow.com/docs/Berp_jj~ssFtZFdHRWBefw)**   
  Use the `${}` or `gs.getMessage()` syntax in the HTML Template, Client Script, or Server Script fields of a widget to tag strings for translation so you can localize your Service Portal content.
* **[Replace a Service Catalog form script with a widget](https://www.servicenow.com/docs/Zuu2Hewx4dq~3UaV_GtqoA)**   
  You can use widgets in Service Portal to replace UI Macros. If your Service Catalog form includes a UI Macro that references other fields or variables on the form, you can create a widget to hold reusable code and embed it within the Service Catalog form. Use special syntax to access any variable fields on the form.
* **[Widget troubleshooting guide](https://www.servicenow.com/docs/FJ5Me_TSO0hB4YvJZOAQoA)**   
  Use the following tools to investigate and resolve unexpected behavior in your custom Service Portal widgets.
* **[Embeddables in Service Portal](https://www.servicenow.com/docs/1_VbQ8FITYQVlN2saJkk~A)**   
  Embeddables are UI Builder components that you can embed into Service Portal pages, external websites, and other web interfaces. Using embeddables, you can reuse existing components across multiple platforms without requiring an AngularJS rebuild. Embeddables enable low-code configuration of components, reducing development time and improving integration flexibility across your ServiceNow® ecosystem.

