setAttributes

Set the values of the fields of this CMS item. May return null if the item was deleted before this method was called.

const updatedItem = await collectionItem.setAttributes({
  slug: "new-slug",
  fieldData: {
    [ageField.id]: { type: "number", value: 48 },
  },
})

Omitted top-level fields remain unchanged. Supplied arrays replace their items and nested field data; include everything to keep. Reuse array item IDs to preserve matching localized values, or omit IDs to create new items. Pass value: [] to clear an array.

Parameters

Returns

  • Promise<CollectionItem | null> – The updated CollectionItem, or null if the item no longer exists.