# Error with hooks : cannot set property of undefined

**URL:** <https://community.forestadmin.com/t/error-with-hooks-cannot-set-property-of-undefined/6107>\
**Category:** Help me!\
**Tags:** smart-action\
**Created:** [March 22, 2023, 4:23pm UTC](https://community.forestadmin.com/t/error-with-hooks-cannot-set-property-of-undefined/6107 "2023-03-22T16:23:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mduhez](https://avatars.discourse-cdn.com/v4/letter/m/4af34b/32.png) [@mduhez](https://community.forestadmin.com/u/mduhez)\
**Post date:** [March 22, 2023, 4:23pm UTC](https://community.forestadmin.com/t/error-with-hooks-cannot-set-property-of-undefined/6107/1 "2023-03-22T16:23:37Z")

</div>

## Feature(s) impacted

A smart action is not loading properly

## Observed behavior

When opening a smart action, we have an error in our backend for a hook. The action is a copy from another project with an old version, maybe we have to update our hook ?

## Expected behavior

No error and our smart action is accessible for the user

## Failure Logs

[forest]Error in smart load action hook: Cannot set properties of undefined (setting ‘enums’)

## Context

- Project name: biben
- Team name: operations
- Environment name: develoment
- Database type: postgresql

---

<div class="post-metadata">

**Author:** ![mduhez](https://avatars.discourse-cdn.com/v4/letter/m/4af34b/32.png) [@mduhez](https://community.forestadmin.com/u/mduhez)\
**Post date:** [March 22, 2023, 4:25pm UTC](https://community.forestadmin.com/t/error-with-hooks-cannot-set-property-of-undefined/6107/2 "2023-03-22T16:25:13Z")

</div>

here is the code, the error is on the line : fields[‘Identité’].enums = …

 ![MicrosoftTeams-image (2)](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/e/ef7b56b59d3ba8494f72e485e403f28525ab32d7.png)

---

<div class="post-metadata">

**Author:** ![anon39940173](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@anon39940173](https://community.forestadmin.com/u/anon39940173)\
**Post date:** [March 22, 2023, 4:35pm UTC](https://community.forestadmin.com/t/error-with-hooks-cannot-set-property-of-undefined/6107/3 "2023-03-22T16:35:09Z")

</div>

Hello @mduhez

Here is the migration guide: [Upgrade to v8 - Developer guide](https://docs.forestadmin.com/documentation/how-tos/maintain/upgrade-notes-sql-mongodb/upgrade-to-v8#smart-actions)

The change in your case should be

```javascript
// before
const identity = fields['identité'];

// after
const identity = fields.find(f => f.field === 'identité')

```

Note that change hooks have also changed if you are using those.

---

<div class="post-metadata">

**Author:** ![Soufiane](https://avatars.discourse-cdn.com/v4/letter/s/8edcca/32.png) [@Soufiane](https://community.forestadmin.com/u/Soufiane)\
**Post date:** [March 27, 2023, 6:27am UTC](https://community.forestadmin.com/t/error-with-hooks-cannot-set-property-of-undefined/6107/4 "2023-03-27T06:27:53Z")

</div>

thank you for this reply
