Configure a Content Selector From Scratch
If you prefer to create your own content selector for Salesforce CMS that connects an external content system, these are the main steps involved.
- Define the DgtAssetMgmtProvider type, which provides basic provider information.
- Create a LightningComponentBundle that implements a user interface for the external content provider in the CMS content editor.
- Configure the DgtAssetMgmtPrvdLghtCpnt type, which links the external provider to the component.
- Set up DgtAssetMgmtProviderInstance for the runtime configuration. See CMS Digital Asset Management Providers in the Connect REST API Developer Guide.
- Deploy and test the complete integration.
To create a provider instance, you can use Apex code. You can create multiple provider instances, each using its own URL and Lightning web component, but there can be only one default instance.
In this Apex example:
- Replace
yourProviderLabelwith the name of your provider’s label. - Replace the value assigned to
input.namewith the name of your instance. - Replace the value assigned to
input.instanceUrlwith the URL of your instance.
A JSON object with the following context property shape is set on the custom Lightning component instance when created from the component definition.
| Name | Value | Preview Available |
|---|---|---|
| Audio | AUDIO | Yes |
| Document | DOCUMENT | No |
| Image | IMAGE | Yes |
| Video | VIDEO | Yes |
| Property | Type | Description | Constraints |
|---|---|---|---|
spaceId | string | CMS Enhanced Workspace ID | Standard 18 characters |
mediaType | string | Requested media type | One of Media Type values |
instanceKey | string | A key that uniquely identifies the Digital Asset Provider instance | Max 255 characters |
isBuilder | boolean | Indicator to determine whether the context is launched from Experience Builder |
When the user selects an external asset, your custom Lightning web component must fire an assetselected event with a payload that can be associated with the CMS content item, such as in this example.
| Event | Property | Type | Required | Constraints |
|---|---|---|---|---|
| assetselected | url | string | Yes | Max 2000 chars. |
contentInfo.title | string | Yes | Max 255 chars | |
contentInfo.altText | string | No | Max 255 chars | |
contentInfo.externalId | string | No | Max 255 chars. Every asset click will be treated as new content if externalId is not provided. | |
contentInfo.urlName | string | No | Max 255 chars, alphanumeric content slug with lowercase letters, and without spaces (use hyphen instead). Will be derived from title if not provided |