Load hook is not firing / working on smart action

Expected behavior

On a smart action get the load hook to kick in on load. It’s not happening. Not setting value, nor printing log, nor stopping at break point.

Actual behavior

It’s not being fired so it is as it’s not being defined.

Failure Logs

no failure log when opening smart action on UI. It’s showing the action. It’s loading it but the fields of enum are still empty so no option showing on dropdown.

Context

This is the smart action with the load hook setup

{
  name: 'lorem',
  endpoint: '/forest/actions/add-lorem',
  type: 'bulk',
  fields: [
    {
      field: 'select items',
      type: 'Enum',
      enums: [],
    },
  ],
  hooks: {
    load: async ({ fields, record }) => {
      console.log('not being executed')
      return fields
    },
  },
}

Setup

  • Package Version: “forest-express-sequelize”: “^6.7.11”
  • Express Version: “express”: “~4.16.3”
  • Sequelize Version: “sequelize”: "~5.15.1
  • Database Dialect: “postgres”
  • Database Version: “pg”: “^8.5.1”

Hello @rofi, and welcome to the Forest Admin community :tada:

Load hook only works with single smart action. The bulk type is not supported yet.
You can read the documentation to find more information about this feature :slight_smile:

I hope it helps you :slight_smile:

Hey @Guillaume_Cisco . Yes, it answers my question thanks. But I got you another one :slight_smile: Is there a workaround or other approach to pickup async data for bulk actions? Seems like a normal use case.

Yes @rofi,

You can still use the deprecated feature values, check this part in the old documentation :slight_smile:

to use it I need to downgrade to v5 @Guillaume_Cisco ? It’s not picking up on v6.

You don’t need to downgrade to v5, you can still use it, but you will have a warning message.

So values is only working for single smart actions too :cry: Any thoughts @Guillaume_Cisco ?

Indeed, values will also work with single smart actions.
As a workaround, you could use defaultValue for each field. It won’t be dynamic, but will allow you to declare basic default values for your fields.

Let me know if it helps :slight_smile:

I think the answer is that ForestAdmin lacks full bulk editing capabilities. Not seeing a workaround here. Thanks anyway @Guillaume_Cisco for the help.

Hi @rofi.

I pushed this as an insight on our ProductBoard, since the current load hooks is not designed to work on bulk smart action.

Great @jeffladiray . I don’t know the constraint on not letting the hook be called on bulk. Surely there is a why. In my case, I want to on load set an enum with an async query for a database collection. Putting it here just to see if you think there is another way to do this. To close all options. But that functionality seems to be off-limits without the hook.

2 Likes