QUESTPIE
Build Your WorkspaceActions

Custom Actions

Define custom actions with forms, confirmation dialogs, and server-side handlers.

Custom actions extend the admin with domain-specific operations — bulk status changes, exports, notifications, or any workflow step.

Defining Custom Actions

Custom actions can be added to collections with forms and handlers:

// Collection with custom action
.admin(({ c }) => ({
  label: { en: "Appointments" },
  actions: [
    {
      id: "mark-completed",
      label: { en: "Mark as Completed" },
      icon: c.icon("ph:check-circle"),
      handler: async ({ ids, collections }) => {
        for (const id of ids) {
          await collections.appointments.update({
            where: { id },
            data: { status: "completed" },
          });
        }
      },
    },
    {
      id: "cancel-with-reason",
      label: { en: "Cancel Appointment" },
      icon: c.icon("ph:x-circle"),
      confirm: { en: "Are you sure you want to cancel?" },
      form: {
        reason: {
          type: "textarea",
          label: { en: "Cancellation Reason" },
          required: true,
        },
      },
      handler: async ({ ids, formData, collections }) => {
        for (const id of ids) {
          await collections.appointments.update({
            where: { id },
            data: {
              status: "cancelled",
              cancellationReason: formData.reason,
              cancelledAt: new Date(),
            },
          });
        }
      },
    },
  ],
}))

Action Options

OptionTypeDescription
idstringUnique identifier
labelstring | i18nButton label
iconIconButton icon
confirmstring | i18nConfirmation dialog text
formobjectForm fields shown before execution
handlerfunctionServer-side handler
bulkbooleanAvailable as bulk action in list view

On this page