Load hook - prefill a form with default values doesn't work (suspected bug with v7.9.2)

Hi Guys.
We just upgraded forest-express-sequelize from v6.6.3 to v7.9.2 and we have a regression in something that in v6 was working correctly.

Following the docs we can prefill a smart action form with a default value from the data available in the selected record: https://docs.forestadmin.com/documentation/reference-guide/actions/create-and-manage-smart-actions#prefill-a-form-with-default-values

We’re doing that. But with v7 this is not working anymore:

As shown in the screenshot, we’re just putting the amount from a field of the record we selected into a field of the smart action form.
But an error is thrown.
It looks like the field is not present in the record we get passed by the load hook.

As far as I can see, the record we receive with v7 is not a Sequelize instance any more. In v6 this was a sequelize instance. And in your docs the record is supposed to be a sequelize instance.
Now, I can find my data in the dataValues property of the record. But the record is an Object, not a sequelize instance. And there are not the fields at the “first level”. It looks like you have some kind of copy of the object… but the first level getters available in the sequelize instance are gone.
We’re introducing a workaround by accessing the datavalues everywhere in our project… but… may you please acknowledge and help?
Because, as far as I can tell, the code in your documentation (see the link above) can’t work with v7.9.2.

Or am I missing something?

Here is my code:

hooks: {
  load: async ({ fields, record }) => {
    console.log(record.amountDue) // undefined, even if this field is available in my model!
    console.log(record.dataValues.amountDue) // I can see the correct value here
    console.log(typeof record) // Object (but a sequelize instance was expected here)
    const { amountDue } = record
    fields.amount.value = someFunction(amountDue) // someFunction breaks with undefined value
    return fields

In your docs this is the example:

// ...
    hooks: {
      load: ({ fields, record }) => {
        fields.amount.value = 4520;
        fields.stripe_id.value = record.stripe_id; // <--- this can't work: it's undefined
        return fields;
// ...

forest-express-sequelize: 7.9.2
sequlize: ^5.22.3
project name: sailsquare

Hello @Matteo,

Thanks for your detailed report. We just spotted this bug today.

Our team is already on it. I will link your thread so they can update you once we released a fix. :slight_smile:

Best regards,

1 Like

Thank you @morganperre
Looking forward to have the fix soon.

Thank you.

1 Like

Hello @Matteo, we’ve just released a new version of forest-express-sequelize :tada:

Could you update to the 7.9.3 version?

Let me know :wink:


Thank you @Guillaume_Cisco
We updated right now and I can confirm this is fixed :+1:

I’m wondering how nobody experienced the same problem since FES 7.4… maybe we’re pioneers :muscle: :grinning_face_with_smiling_eyes:

Thank you for your willingness and your speed!!