Actions
Last updated
Was this helpful?
Last updated
Was this helpful?
This is the official documentation of Forest Admin Cloud.
Actions allow users to trigger custom HTTP API calls, encapsulating custom business logic or initiating workflows on third-party tools. These actions are shown as buttons on the admin panel and are connected to specific collections to make sure they are related to the data being handled.
Before proceeding with this section to learn how to create an action using Code customization, it is recommended to first , which is quicker and easier. This section aims to provide you with the most flexibility in creating actions, including advanced customization options.
Ensure you update the collection and action names as needed.
First, you need to call the customizeCollection()
method on the agent.
Arguments:
name
* String: The name of the collection to customize.
handle
* Function: A function that has the collection instance as an argument to start customizing it.
Next, you can invoke the addAction()
method on the collection instance to create an action in Forest Admin:
Arguments:
name
* String: The name of the action.
definition
* Object: A JavaScript object that contains the definition of the action:
execute
* Function: An async function that contains your business logic, which is executed when your action is triggered.
The scope of an action refers to the targeted range of records when triggering an action. There are 3 types of scopes:
Single: Enables you to execute an action on a single, specifically chosen record.
Bulk: Empowers you to trigger the action on multiple selected records simultaneously.
Global: Allows you to initiate the action at the collection level without the need to select individual records.
scope
* String: See .
context
Object: See .
resultBuilder
Object: See .