Can't call a load hook in a smart action

Expected behavior

I add the next piece of code

collection('feeRules', {
  actions: [
    {
      name: "Create",
      type: "global",
      httpMethod: "POST",
      fields: [
        {
          field: InputFields['Name'],
          description: `Name of the fee rule`,
          type: 'String',
          isRequired: true,
        },
    ],
    hooks: {
       load: ({fields, record}) => {
          console.log('hello world')
       }
    }

And expect hello world in my console,

Actual behavior

I don’t see anything.
I also tried to assign some dynamic fields to “fields” property inside the load method
and return it but nothing worked out for me.

Failure Logs

Nothing, no errors.

Context

“dependencies”: {
“axios”: “^0.21.1”,
“body-parser”: “1.19.0”,
“chalk”: “~1.1.3”,
“cookie-parser”: “1.4.4”,
“cors”: “2.8.5”,
“debug”: “~4.0.1”,
“dotenv”: “~6.1.0”,
“express”: “~4.17.1”,
“express-jwt”: “6.0.0”,
“forest-express-sequelize”: “^7.0.0”,
“morgan”: “1.9.1”,
“pg”: “~8.2.2”,
“require-all”: “^3.0.0”,
“sequelize”: “~5.15.1”
}

  • Database Dialect: postgresql
  • Database Version: 13

Hi @Francois_Vongue,

As mentioned in the documentation, I think this feature is only available for “single” action types…

All the best

Thank you! Did’t notice it.
Any idea how can I populate an enum field in a global action?

1 Like

I don’t have the answer to that… Maybe someone at Forest will :raised_hands: They might be off today with the 14th of July.

1 Like

Hi @Francois_Vongue,

Using load hook in global actions is available from version 8 of forest-express-*.

To populate an enum field in global action (or any type of action), you have to set to 'Enum' the field type and define the enums list:

      {
        field: 'exampleField',
        type: 'Enum',
        enums: ['one', 'two', 'three'],
      }

Of course, this is to be done in the fields array of your action.
This is described here

Regards

1 Like