Table of Contents

Custom actions — a toolbar/bulk button that runs server logic

Grounded against origin/releases/7.0 (MibServer3 HandlerV2Controller/IHandler + the customization-repo [AjaxMethod]/DefaultHandler pattern; real example tvopenplatform-mib3 · CatalogExporterV2Component).

When a page needs a custom action — "Publish all selected", "Export now", "Re-sync" — that runs server-side logic beyond stock create/edit/delete, you add a method to a custom component and expose it as an [AjaxMethod]. The React shell calls it through the handler dispatch endpoint; you guard it with the component's Permissions. The server path is fully grounded; the button's placement in the toolbar is declared in the React remote (see the caveat) — not in a server schema.

MIB 7.1 — no custom component needed. A stock component serves its own endpoint: subclass FormComponent, ListComponent, a related list or OrderedRelatedListComponent, override GetHandler() (public virtual from 7.1) and hand what you do not handle to base.GetHandler() — Host your own endpoint on a stock component (mib get recipe.host-endpoint-on-stock-subclass). On 7.0 only List and Related can, through public new IHandler GetHandler(); Form and Ordered have no handler. The button is still declared in the remote — on a stock list or form, as a decorator: list item and header actions from cms-2.54.0, the edit header's contentEdition.headerActions from cms-2.37.0.

The grounded mechanism ([AjaxMethod] + the handler endpoint)

  1. Mark a method on your custom component (subclass of MibComponent) with [AjaxMethod]:
[AjaxMethod(Component.HttpMethod.Post)]
public MibActionResult PublishSelected(PublishParams param)
{
    // selected rows arrive on the component (from __IDs); params from __PARAMETERS
    var perm = Permissions.Get(MediaTypeNames.MyEntity);       // real guard — see below
    if (!perm.CanWrite) return Error("Not permitted");

    // ... do the work (call a workflow, mib.api via ApiClient, an external system) ...
    return Success("Published");                                // MibActionResult: Success/Error/Info/Warning/View
}

Real production example: tvopenplatform-mib3 · src/Pages/GVP.Mib3.CatalogExporterReact/CatalogExporterV2Component.cs:85-95 ([AjaxMethod(Post)] ExportNow(...), guarded by Permissions.GetCustomPermissions()).

  1. Dispatch — the shell POSTs to the handler endpoint (HandlerV2Controller, /api/v2/handler/{pageKey}/{templateComponentKey}), which routes to your component's GetHandler() → DefaultHandler, which reads the query and reflects to the [AjaxMethod] (MibComponent.DynamicInvokeMethod):
POST /api/v2/handler/{pageKey}/{componentKey}?__ACTION=PublishSelected&__IDs=1,2,3&__PARAMETERS={...}
  • __ACTION = the method name · __IDs = the selected row ids (empty ⇒ a global action; populated ⇒ selection-scoped) · __PARAMETERS = JSON args (querystring for GET, body for POST).
  • The method returns a MibActionResult (Success / Error / Info / Warning / View) the shell renders.

Guarding it (the REAL permission checks)

Guard inside the method with the component's Permissions — there is no Context.User.HasCapability() (that helper does not exist; do not use it):

  • Permissions.Get(mediaType) → a MediaTypePermission { CanRead, CanWrite, CanCreate, CanDelete }.
  • Permissions.GetCustomPermissions() → your configurable/custom permission flags (building-block.configurable-permission — the CatalogExporter gates on a custom DeltaExportPermissions).
  • Context.User exposes MediaTypePermissions + SourcePermissions (UserViewData.cs:48-51) — no IsAdministrator, no capability helper. Source scope also applies (building-block.content-source).

Scope

  • Global (toolbar-level, whole list/page) — __IDs empty.
  • Selection-scoped (act on the checked rows) — __IDs=1,2,3.
  • Per-row custom action — CANNOT-CONFIRM a dedicated mechanism; per-row is usually the stock edit/delete/clone affordances, so model a custom per-row action as a selection of one (or a custom component).

The button UI — the one honest gap

The server handler + dispatch + guard are grounded. What declares the button in the toolbar is not in a server schema — there is no ListSchema.Actions / ItemV2ViewData.Actions; the button is wired in the React remote (it calls /api/v2/handler/…?__ACTION=…, e.g. MIBFrontEnd-GVP-components · src/components/parameter/api/index.ts:18-21). So adding a visible button means touching the page's React remote, not just server config — treat that as remote work and confirm against the specific remote you're extending.

The core ActionRegistry (ActionPipeline.cs — Register/WithGuard/DispatchAsync) is an emerging foundation: it exists and is unit-tested, but is not yet wired to an HTTP endpoint or the UI (CANNOT-CONFIRM any production use). Use the [AjaxMethod] path today; don't build on ActionRegistry expecting a stock button.

Gotchas (grounded)

  1. [AjaxMethod] is the customization-repo pattern, not core MibServer3 — it lives on components in tvopenplatform-mib3; you add it to a custom component, so this is the custom-component tier, not config.
  2. No HasCapability/IsAdministrator — guard with Permissions.Get(...) / GetCustomPermissions() / SourcePermissions. Anything else is fabricated.
  3. The button is remote-side — a server [AjaxMethod] alone renders no button; the React remote must call the handler URL. Plan for remote work.
  4. Long-running actions — the handler is a request/response; for slow work (a big export) return quickly and hand off to an async job that notifies on completion (building-block.notifications, as the TSV exporter does).
  5. Selection semantics — __IDs is what the client sends; validate it server-side (don't trust an empty set to mean "all" unless you intend a global action).

Discover

mib get building-block.custom-actions · mib get recipe.custom-toolbar-action · guard it: mib get building-block.configurable-permission · async hand-off: mib get building-block.notifications · a real export action: mib get building-block.tsv-export.