---
sourceDocument: Australia Customer Service Management
sourceDocumentLink: https://www.servicenow.com/docs/r/australia/customer-service-management

 Release :

    - australia

ft:locale :

    - en-US

ft:publication_title :

    - Australia Customer Service Management

ft:clusterId :

    - csm

bundleId :

    - csm

workflow :

    - Customer and Industry


---

# Functions available in Web Embeddables global and component code

# Functions available in Web Embeddables global and component code {#ariaid-title1}

Release version: Australia  
Updated March 12, 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 2 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 Functions available in Web Embeddables global and component code

This guide explains how to use the ServiceNow Embeddables API to integrate ServiceNow components into external websites.
It details global and component-level functions that enable initialization, authentication, component management, and event handling for embedded ServiceNow components.
Show full answer Show less  

## Global Code Functions

* **init()**: Initializes the embeddables framework and must be called first. It configures settings such as theme, instance URL, authentication callback, locale, session timeout handling, and optionally pre-caches components to improve performance. It also updates the user's language preference for authenticated users.
* **login()** : Authenticates users by invoking the authentication callback provided during initialization. Requires a prior successful init() call. On successful login, it dispatches an *SNEMBEDDABLESLOGINSUCCESS* event.
* **logout()** : Logs out the authenticated user from the ServiceNow session. Requires prior init() and a logged-in user. On logout success, it dispatches an *SNEMBEDDABLESLOGOUTSUCCESS* event.

## Component Code Functions

* **getEmbeddables(components)**: Loads and initializes an array of specified embeddable components by their tag names.
* **setProperties(componentElement, properties)**: Sets key-value property pairs on a specific embeddable component instance, allowing customization such as selecting records or configuring display options.
* **setEvents(componentElement, eventHandlers)**: Attaches event listeners to embeddable components to handle lifecycle events such as readiness and errors, enabling dynamic response within the embedding page.

## Key Considerations for Implementation

* Always call **init()** first to establish the framework and configuration.
* Use event handlers to monitor component lifecycle states and error conditions for robust integration.
* Pre-cache frequently used components via the **cacheComponents** option in **init()** to enhance load times and performance.

By leveraging these functions, ServiceNow customers can seamlessly embed and manage ServiceNow components on external websites with consistent authentication, localization, and session management, resulting in a smooth user experience and simplified integration.  
Use these functions to initialize, authenticate, manage components, and handle events when you embed ServiceNow components on external websites.

## Global code {#we-global-code-functions__section_rmr_jvl_bgc}

The ServiceNow Embeddables API integrates ServiceNow components into your external websites.  
The embed script includes the following methods as part of the global code. The following details help you understand how they work.

Init method
:
    * Purpose: Initializes the embeddables framework with configuration settings.
    * Usage pattern:

          await init({
          	theme: 'fad87d2ca304121029a4d1aed31e610f', //sys_id of theme,
          	baseURL: 'https://demo.servicenow.com',
          	authCallback: getTokenCallBack, // Authentication callback function 
                 locale: 'ja', // Language/locale for components
                 interceptSessionTimeout: true, // Handle session timeouts (default: true)
          	// cacheComponents: [ //Pre-cache component for performance  "sn-embedx-case-form", "sn-embedx-case-list", "sn-embedx-case-view" ]
          });

    * Parameters:
      * `authCallback` (Function): Returns authentication token for the current user.
      * `baseURL` (String): Base URL of the ServiceNow instance.
      * `locale` (String, optional): Language/locale setting (for example, 'en', 'es') that updates the user's language preference in ServiceNow for authenticated user.
      * `theme` (String): The sys_id of theme to apply.
      * `interceptSessionTimeout` (Boolean, optional): Enable session timeout handling. By default, it is set to <kbd class="ph userinput">true</kbd>.
      * `cacheComponents` (Array, optional): List of component tag names to pre-cache.
      {#we-global-code-functions__ul_ilk_2cm_bgc}
    * Key behaviors:
      * Must be called before any other embeddables functions.
      * Loads necessary resources and establishes a connection.
      * Optionally sets up interceptors for session management.
      * Updates the user's language preference for the authenticated user if locale is provided.
      * Pre-caches specified components for improved performance.
      {#we-global-code-functions__ul_kll_rcm_bgc}
    {#we-global-code-functions__ul_ibr_wxl_bgc}

login()
:
    * Purpose: Authenticates the user with the ServiceNow instance.
    * Usage Pattern:

          await login();

    * Key behaviors:
      * Calls the authCallback function provided during initialization.
      * Authenticates with the returned token - Dispatches SN_EMBEDDABLES_LOGIN_SUCCESS event on success.
      {#we-global-code-functions__ul_u5t_4dm_bgc}
    * Prerequisites: `init()` must be called first with a valid authCallback - authCallback function must return a valid authentication token.
    {#we-global-code-functions__ul_s2s_fdm_bgc}

logout()
:
    * Purpose: Logs out the user from ServiceNow session.
    * Usage pattern:

          await logout();

    * Key behaviors: Dispatches SN_EMBEDDABLES_LOGOUT_SUCCESS event on success.
    * Prerequisite: `init()` must be called first with valid baseURL - User must be logged in.
    {#we-global-code-functions__ul_n15_vdm_bgc}

## Component code {#we-global-code-functions__section_jyc_k2m_bgc}

The embed script includes the following methods as part of the component code. The following details help you understand how they work.

getEmbeddables
:
    * Purpose: Loads and initializes specified embeddable components.
    * Usage pattern:

          // Load components by providing array of component tag names
          getEmbeddables(["sn-embedx-case-view", "sn-embedx-case-form"]);

    * Parameters: `components` (Array): Array of component tag names to load
    {#we-global-code-functions__ul_il2_n2m_bgc}

setProperties(componentElement, properties)
:
    * Purpose: Sets properties on embeddable component instances.
    * Usage pattern:

          const caseViewComponent = document.querySelector('sn-embedx-case-view');
          setProperties(snEmbedxCaseView,{
          		table:sn_customerservice_case,
          		sysId:221a69cd3b411300b5c42479b3efc480,
          		playbookExperience:playbookExperience,
          		selectedPlaybookContextId:85d9f349ff766210e9d3ffffffffffce,
          		selectedStageContextId:9da56770ff7a2210e9d3ffffffffffd9,
          		selectedActivityContextId:5d8bf1805d8bf8205d8b54d05d8be070 });

    * Parameters: `componentElm` (HTMLElement): The component DOM element - properties (Object): Key-value pairs of properties to set.
    {#we-global-code-functions__ul_lx3_dfm_bgc}

setEvents (componentElement, eventHandlers)
:
    * Purpose: Attaches event listeners to embeddable components.
    * Usage pattern:

          const caseViewComponent = document.querySelector('sn-embedx-case-view');
          const eventHandlers = {'
          'SN_EMBEDX_CASE_VIEW#COMPONENT_READY': (e) => { 
          console.log('Component is ready and usable'); }, 
          'SN_EMBEDX_CASE_VIEW#COMPONENT_ERROR': (e) => { const 
          { errorMessage, errorType } = e.detail.payload;
          console.log('Component error:', errorMessage, errorType); },
          };
          setEvents(caseViewComponent, eventHandlers); 

    * Parameters: `componentElm` (HTML Element): The component DOM element - eventHandlers (Object): Key-value pairs where keys are event names and values are handler functions.
    {#we-global-code-functions__ul_wgy_3gm_bgc}

## Key considerations {#we-global-code-functions__section_xmz_zyz_bgc}

Here are some key considerations to help you implement this effectively:

* Ensure to call init() first. It sets up the foundation for all other functions.
* Use event handlers for the component life-cycle. It also monitor component readiness and errors.
* Cache frequently used components. Use cacheComponents in init() for better performance.
* Implement
{#we-global-code-functions__ul_kq1_2zz_bgc}

