Develop Secure Code
getContent
getContext
updateContent
updateContentUpdates the title and contentBody of the content item in the content editor of an enhanced CMS workspace. Updates are persisted when the user clicks Save in the content editor.
You can use this.context.data.schema.schema.properties to return the list of contentBody property fields for the content type.
1import { LightningElement, wire } from 'lwc';
2import { updateContent } from experience/cmsEditorApi;
3class Example extends LightningElement{
4 // change the content in the editor
5 updateContent({
6 "title": "new title",
7 "contentBody: {
8 "name": "New name",
9 "description": "New description",
10 "excerpt": "new-excerpt"
11 }
12 }).then(() => {
13 //handle success
14 })
15}| Parameter Name | Type | Description | Required? |
|---|---|---|---|
contentBody | Object | The JSON representation of the content body, which varies depending on the content type. See JSON File Format for Content in Salesforce CMS in Salesforce Help. | ![]() |
title | String | The new title of the content item in the editor. | ![]() |
updateContent response is returned.error—A validation error for invalid fields.