Create a Service Portal widget with embeddables

task brazil Updated Sep 25, 2026 1 min read create-service-portal-widget-embeddables.md
Raw file servicenow.com

Create a Service Portal widget that displays an embeddable component. Add the component to the widget HTML and then call the embeddable APIs in a widget client script.

Before you begin

Role required: admin

Procedure

  1. In the widget HTML template file, add the embeddable component using its tag name.

    XML
    <case-list data-test-id="case-list" data-filter-config="$ctrl.filters"></case-list>
  2. Replace case-list with the tag name of your embeddable component.

  3. In your widget client controller, inject the spEmbeddables service.

    For example:

    JavaScript
    app.controller('caseListWidget', function($scope, spEmbeddables) {  // Widget logic here});
  4. Call the getEmbeddables() method to retrieve the component data by tag name.

    For example:

    JavaScript
    app.controller('caseListWidget', function($scope, spEmbeddables) {  spEmbeddables.getEmbeddables(['case-list']).then(function(components) {    $scope.caseList = components['case-list'];  });});
  5. Register event handlers.

    For example:

    JavaScript
    $scope.setupEvents = function() {  var caseListElement = document.querySelector('case-list');  spEmbeddables.setEvents(caseListElement, {    onSelect: $scope.onCaseSelect,    onUpdate: $scope.onCaseUpdate  });};
    $scope.onCaseSelect = function(caseId) {  spUtil.addInfoMessage('Case ' + caseId + ' selected');};
  6. Use the setProperties() method to dynamically change component properties.

    For example:

    JavaScript
    $scope.updateFilter = function(newFilter) {  var caseListElement = document.querySelector('case-list');  spEmbeddables.setProperties(caseListElement, {    filterConfig: newFilter  });};
  7. Add the widget to a Service Portal page.

    For more information, see Create and edit a page using the Service Portal Designer.

  8. Load the portal page in a browser and verify that the embeddable component displays and functions as expected.

Result

Your Service Portal widget displays and interacts with the embeddable component.

Parent Topic:Embeddables in Service Portal

Search documentation
Search document titles and file paths on the brazil branch