Links

Actions

Sooner or later, you will need to perform actions on your data that are specific to your business.
Moderating comments, generating invoices, logging into a customer’s account, or banning users are exactly the kind of important tasks to unlock to manage your day-to-day operations.
Custom Action displayed in a Table View

In your code

To create an Action, you will first need to declare it in your code for a specific collection. Here we declare a "Mark as Live" Action for the companies collection.
from typing import Union
from forestadmin.datasource_toolkit.interfaces.actions import ActionsScope
from forestadmin.datasource_toolkit.decorators.action.context.single import (
ActionContextSingle
)
from forestadmin.datasource_toolkit.decorators.action.result_builder import (
ResultBuilder
)
from forestadmin.datasource_toolkit.interfaces.actions import ActionResult
async def execute(
context: ActionContextSingle, result_builder: ResultBuilder
) -> Union[None, ActionResult]:
pass
# implement your controller here
agent.customize_collection("User").add_action("Mark as live", {
"scope": ActionsScope.SINGLE,
"execute": execute, # this method can be a callable, awaitable or a lambda
})

In the admin panel

After declaring it, the Action will appear in the Smart Actions tab within your Collection Settings.
An Action is displayed in the UI only if:
  • it is set as "visible" (see screenshot below) AND
  • in non-development environments, the user's role must grant the "trigger" permission
You must make the Action visible there if you wish users to be able to see it in this Team.
Making the Action visible