From 7eafc5b0efc2bb56328f03a0c794407df2227189 Mon Sep 17 00:00:00 2001 From: Ben Szymanski Date: Wed, 22 Oct 2025 00:10:09 -0500 Subject: [PATCH 1/2] Complete article with up to date code samples and additional insights. --- .../extension-types/entity-bulk-actions.md | 65 +++++++++++++------ 1 file changed, 45 insertions(+), 20 deletions(-) diff --git a/16/umbraco-cms/customizing/extending-overview/extension-types/entity-bulk-actions.md b/16/umbraco-cms/customizing/extending-overview/extension-types/entity-bulk-actions.md index 797b5aebc15..fa84523976b 100644 --- a/16/umbraco-cms/customizing/extending-overview/extension-types/entity-bulk-actions.md +++ b/16/umbraco-cms/customizing/extending-overview/extension-types/entity-bulk-actions.md @@ -1,17 +1,21 @@ +--- +description: Bulk Entity Actions perform an action on a selection of items. +--- + # Entity Bulk Actions -{% hint style="warning" %} -This page is a work in progress and may undergo further revisions, updates, or amendments. The information contained herein is subject to change without notice. -{% endhint %} +Extension authors can register an entity bulk action to appear in the context menu of a collection view. The manifest passes control over to a custom `UmbEntityBulkActionBase` class that will be instantiated and executed when the action is clicked. The class will have access to the host element and a selection of items to perform the action on. -**Entity Bulk Action:** Relates to an entity type: document, media, etc. Performs the action on a selection of items. +When the action is completed, an event on the host element will be dispatched to notify any surrounding elements.

Entity Bulk Collection

## Registering an Entity Bulk Action +Entity Bulk Action extensions can be included by importing a subclass of `UmbEntityBulkActionBase` to the `api` property. Placement within the backoffice can be controlled using the conditions property. + ```typescript -import { extensionRegistry } from '@umbraco-cms/extension-registry'; +import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry'; import { MyEntityBulkAction } from './entity-bulk-action'; const manifest = { @@ -23,7 +27,6 @@ const manifest = { meta: { icon: 'icon-add', label: 'My Entity Bulk Action', - repositoryAlias: 'My.Repository', }, conditions: [ { @@ -33,25 +36,47 @@ const manifest = { ], }; -extensionRegistry.register(manifest); +umbExtensionsRegistry.register(manifest); ``` ## The Entity Bulk Action Class -As part of the Extension Manifest you can attach a class that will be instantiated as part of the action. It will have access to the host element, a repository with the given alias and the unique (key etc) of the entity. When the action is clicked the `execute` method on the api class will be run. When the action is completed, an event on the host element will be dispatched to notify any surrounding elements. +Entity Bulk Action extensions subclass `UmbEntityBulkActionBase`, which expects the extension author to provide an implementation of `execute()`. The `UmbEntityBulkActionBase` class provides `this.selection` as a property, which contains a list of uniques from the content nodes that were selected by the user. + +{% hint style="info" %} +This code sample demonstrates overriding the constructor, which could be helpful in certain circumstances, such as consuming contexts. Extension authors can safely omit the constructor if no such need exists. +{% endhint %} ```typescript -import { UmbEntityBulkActionBase } from '@umbraco-cms/entity-action'; -import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; -import { MyRepository } from './my-repository'; - -export class MyEntityBulkAction extends UmbEntityBulkActionBase { - constructor(host: UmbControllerHostElement, repositoryAlias: string, selection: Array) { - super(host, repositoryAlias, selection); - } - - async execute() { - await this.repository?.myBulkAction(this.selection); - } +import { + UmbEntityBulkActionBase, + UmbEntityBulkActionArgs, +} from "@umbraco-cms/backoffice/entity-bulk-action"; +import { UmbControllerHostElement } from "@umbraco-cms/backoffice/controller-api"; + +export class MyBulkEntityAction extends UmbEntityBulkActionBase { + constructor( + host: UmbControllerHostElement, + args: UmbEntityBulkActionArgs, + ) { + // this constructor is optional, override only if necessary + super(host, args); + } + + async execute() { + // perform a network request + // await Promise.all( + // this.selection.map(async (x) => { + // const res = await fetch(`my-server-api-endpoint/${x}`); + // return res.json() as never; + // }) + // ); + + // or fetch repository + // const repository = ... + // await repository.processItems(this.selection); + + console.log(this.selection); + } } ``` From 6f67cefda633704a3ee39e198559cd9f976080e4 Mon Sep 17 00:00:00 2001 From: Ben Szymanski Date: Sun, 2 Nov 2025 23:11:07 -0600 Subject: [PATCH 2/2] Update 16/umbraco-cms/customizing/extending-overview/extension-types/entity-bulk-actions.md Co-authored-by: Richard Jackson --- .../extending-overview/extension-types/entity-bulk-actions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/16/umbraco-cms/customizing/extending-overview/extension-types/entity-bulk-actions.md b/16/umbraco-cms/customizing/extending-overview/extension-types/entity-bulk-actions.md index fa84523976b..e80526661e2 100644 --- a/16/umbraco-cms/customizing/extending-overview/extension-types/entity-bulk-actions.md +++ b/16/umbraco-cms/customizing/extending-overview/extension-types/entity-bulk-actions.md @@ -41,7 +41,7 @@ umbExtensionsRegistry.register(manifest); ## The Entity Bulk Action Class -Entity Bulk Action extensions subclass `UmbEntityBulkActionBase`, which expects the extension author to provide an implementation of `execute()`. The `UmbEntityBulkActionBase` class provides `this.selection` as a property, which contains a list of uniques from the content nodes that were selected by the user. +Entity Bulk Action extensions inherit from `UmbEntityBulkActionBase`, which expects the extension author to provide an implementation of `execute()`. The `UmbEntityBulkActionBase` class provides `this.selection` as a property, which contains a list of uniques from the content nodes that were selected by the user. {% hint style="info" %} This code sample demonstrates overriding the constructor, which could be helpful in certain circumstances, such as consuming contexts. Extension authors can safely omit the constructor if no such need exists.