addAction with Hook


I’m trying to use hooks on Smart Actions. I’m using addAction on CollectionCustomizer, but the ActionDefinition does not contains hooks fields in Typescript.
There is a form field, but no fields as described here :

Is there something that I missed ?



Hello @dscreve

Welcome to the Forest community !

The documentation you posted is on the previous agent.

The documentation you are looking for, for the new agent is right here



Thanks a lot ! That’s perfect !

1 Like

Is there anyway to populate enum from database query (in another collection) ?

You can check this example to see how to populate enum values.

From the context you can get any collection from the same datasource.

You can find the documentation related to the querying through Forest Admin Query Interface

Here is a small example:

 .addAction("Action with populated enum", {
      scope: "Single",
      form: [
          label: "Users email",
          type: "Enum",
          enumValues: async (context) => {
            // Get the collection you want to query
            const usersCollection = context.dataSource.getCollection("users");

            // query the collection
            const users = await usersCollection.list(
                conditionTree: {
                  conditions: [{ field: "id", operator: "LessThan", value: 3 }],
                  aggregator: "And",

            // return an array with your enum values
            return =>;

Thanks : it works fine !

1 Like