Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

UiWidgetBundle (Beta)

Represents a widget. Use widgets to define reusable UI compositions once and deploy them across supported Salesforce applications and third-party platforms. Deploy this bundle to your Salesforce org to make the widget available.

This feature is a beta service that is subject to the Beta Services Terms at Agreements - Salesforce.com or a written Unified Pilot Agreement if executed by Customer, and applicable terms in the Product Terms Directory. Use of this pilot or beta service is at the Customer's sole discretion.

Note

Where possible, we changed noninclusive terms to align with our company value of Equality. We maintained certain terms to avoid any effect on customer implementations.

Important

Parent Type

This type extends the Metadata metadata type and inherits its fullName field.

File Structure and Directory Location

UiWidgetBundle components are stored in the uiWidgets folder.

Here’s an example of the UiWidgetBundle structure.

1+--myMetadataPackage
2    +--uiWidgets (1)
3        +--WIDGET_NAME (2)
4		+--WIDGET_NAME.json (3)
5		+--WIDGET_NAME.uiwidget-meta.xml(4)
6		+--schema.json (5)

The bundle includes these resources.

  • The uiWidgets folder (1) contains a folder for each created widget in the format {widgetName} (2).
  • Each widget folder contains a {widgetName}.json file (3) that defines the JSON UI composition structure for the widget, specifying the component layout, nesting, and data bindings.
  • Each widget folder also contains a  {widgetName}.uiwidget-meta.xml file (4) that defines the widget type. 
  • Finally, an optional schema.json file (5) defines the attribute contract—the attributes and their associated Lightning types the widget accepts.

Version

UiWidgetBundle components are available in API version 67.0 and later.

Fields

Field Name Description
description
Field Type
string
Description

Required. Describes the widget.

masterLabel
Field Type
string
Description

Required. Represents the name of a widget bundle which is defined when the UiWidgetBundle is created.

widgetType
Field Type
string
Description

Required. Represents the widget type. The only allowed value is JSON.

Declarative Metadata Sample Definition

This package.xml file retrieves all the UiWidgetBundle components in an org.

1<?xml version="1.0" encoding="UTF-8"?>
2<Package xmlns="http://soap.sforce.com/2006/04/metadata">
3    <types>
4        <members>*</members>
5        <name>UiWidgetBundle</name>
6    </types>
7    <version>67.0</version>
8</Package>

In the retrieved .zip file, each widget is nested under a uiWidgets folder.

This example shows the directory structure in the .zip file of a widget named hotelCard:

1+--uiWidgets
2        +--hotelCard
3            +--schema.json
4            +--hotelCard.json
5            +--hotelCard.uiwidget-meta.xml

Here are the contents of the files in the hotelCard directory. This sample code shows the contents of the schema.json file.

1{
2  "title": "Hotel Card Widget",
3  "description": "Displays hotel information as a visual card",
4  "type": "object",
5  "properties": {
6    "attributes": {
7      "lightning:type": "lightning__objectType",
8      "properties": {
9        "title": {
10          "title": "Hotel Name",
11          "description": "Primary heading displayed at the top",
12          "lightning:type": "lightning__textType"
13        },
14        "imageUrl": {
15          "title": "Image URL",
16          "description": "URL of the hotel image",
17          "lightning:type": "lightning__urlType"
18        },
19        "price": {
20          "title": "Price Per Night",
21          "description": "Nightly rate displayed as currency",
22          "lightning:type": "lightning__numberType"
23        },
24        "description": {
25          "title": "Description",
26          "description": "Short description of the hotel",
27          "lightning:type": "lightning__textType"
28        }
29      }
30    }
31  }
32}

Contents of the hotelCard.json file.

1{
2  "type": "lightning__agentforceWidget",
3  "contentBody": {
4    "widgetBody": {
5      "definition": "tile/widget",
6      "children": [
7        {
8          "definition": "tile/card",
9          "attributes": {
10            "padding": "lg",
11            "variant": "default",
12            "maxWidth": "full"
13          },
14          "children": [
15            {
16              "definition": "tile/image",
17              "attributes": {
18                "src": "{!$attrs.imageUrl}",
19                "alt": "{!$attrs.title}"
20              }
21            },
22            {
23              "definition": "tile/text",
24              "attributes": {
25                "text": "{!$attrs.title}",
26                "variant": "h3",
27                "weight": "semibold"
28              }
29            },
30            {
31              "definition": "tile/text",
32              "attributes": {
33                "text": "{!$attrs.price}",
34                "variant": "body",
35                "weight": "medium"
36              }
37            },
38            {
39              "definition": "tile/text",
40              "attributes": {
41                "text": "{!$attrs.description}",
42                "variant": "body"
43              }
44            }
45          ]
46        }
47      ]
48    }
49  }
50}

Contents of the hotelCard.uiwidget-meta.xml file.

1<?xml version="1.0" encoding="UTF-8"?>
2<UiWidgetBundle xmlns="http://soap.sforce.com/2006/04/metadata">
3    <masterLabel>Hotel Card</masterLabel>
4    <description>Displays hotel information as a visual card.</description>
5    <widgetType>JSON</widgetType>
6</UiWidgetBundle>

Wildcard Support in the Manifest File

This metadata type supports the wildcard character * (asterisk) in the package.xml manifest file. For information about using the manifest file, see Deploying and Retrieving Metadata with the Zip File.