# Smart Action hooks change doesn't work when upgrating to v8

**URL:** <https://community.forestadmin.com/t/smart-action-hooks-change-doesnt-work-when-upgrating-to-v8/6508>\
**Category:** Help me!\
**Created:** [July 17, 2023, 2:03pm UTC](https://community.forestadmin.com/t/smart-action-hooks-change-doesnt-work-when-upgrating-to-v8/6508 "2023-07-17T14:03:59Z")\
**Posts on this page:** 3\
**Page:** 1

<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:** [July 17, 2023, 2:03pm UTC](https://community.forestadmin.com/t/smart-action-hooks-change-doesnt-work-when-upgrating-to-v8/6508/1 "2023-07-17T14:03:59Z")

</div>

When upgrating to v8 , smart action change hooks doesn’t work.

## Actual behavior

change: {  
[‘Recherche fournisseur (3 lettres minimum)’]: ({ fields, record }) =\> {  
if (fields[‘Recherche fournisseur (3 lettres minimum)’].value.length \> 2) {  
return axios.get(`${API_URL}/forest_admin/sage_providers`, {  
headers: {  
‘Authorization’: `Bearer ${process.env.ACCESS_TOKEN}`,  
‘X-CURRENT-USER-EMAIL’: process.env.SERVICE\_EMAIL  
},  
params: {  
place\_id: ‘’,  
provider\_name: fields[‘Recherche fournisseur (3 lettres minimum)’].value,  
siret: ‘’,  
matricule: ‘’  
}  
}).then(res =\> {  
if (res.data && res.data.length \> 0) {  
fields.find(f =\> f.field === ‘Fournisseur’).enums = res.data.map(provider =\> `${provider.matricule} - ${provider.raison_sociale} - ${provider.site_ville}`)  
}  
return fields;  
});  
}  
return fields;  
}  
}

## Failure Logs

[forest] 🌳🌳🌳 Error in smart action change hook: hook must be a function  
{  
“stack”: “Error: hook must be a function\n at SmartActionHookService.\_callee$ (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\dist\services\smart-action-hook-service.js:78:23)\n at tryCatch (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\regenerator-runtime\runtime.js:63:40)\n at Generator.invoke [as \_invoke] (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\regenerator-runtime\runtime.js:293:22)\n at Generator.next (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\regenerator-runtime\runtime.js:118:21)\n at asyncGeneratorStep (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\node\_modules\@babel\runtime\helpers\asyncToGenerator.js:3:24)\n at \_next (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\node\_modules\@babel\runtime\helpers\asyncToGenerator.js:25:9)\n at C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\node\_modules\@babel\runtime\helpers\asyncToGenerator.js:32:7\n at new Promise ()\n at SmartActionHookService. (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\node\_modules\@babel\runtime\helpers\asyncToGenerator.js:21:12)\n at SmartActionHookService.getResponse (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\dist\services\smart-action-hook-service.js:138:29)\n at \_callee2$ (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\dist\routes\actions.js:117:56)\n at tryCatch (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\regenerator-runtime\runtime.js:63:40)\n at Generator.invoke [as \_invoke] (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\regenerator-runtime\runtime.js:293:22)\n at Generator.next (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\regenerator-runtime\runtime.js:118:21)\n at asyncGeneratorStep (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\node\_modules\@babel\runtime\helpers\asyncToGenerator.js:3:24)\n at \_next (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\node\_modules\@babel\runtime\helpers\asyncToGenerator.js:25:9)\n at C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\node\_modules\@babel\runtime\helpers\asyncToGenerator.js:32:7\n at new Promise ()\n at C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\node\_modules\@babel\runtime\helpers\asyncToGenerator.js:21:12\n at C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\dist\routes\actions.js:144:24\n at Layer.handle [as handle\_request] (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\express\lib\router\layer.js:95:5)\n at  
next (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\express\lib\router\route.js:137:13)\n at dispatch (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\compose-middleware\lib\index.js:46:24)\n at next (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\compose-middleware\lib\index.js:51:24)\n at ipAuthorizer (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\dist\middlewares\ip-whitelist.js:25:12)\n at C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\dist\services\auth.js:61:10\n at dispatch (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\compose-middleware\lib\index.js:63:32)\n at next (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\compose-middleware\lib\index.js:51:24)\n at ensureAuthenticated (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\dist\services\auth.js:31:10)\n at dispatch (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\compose-middleware\lib\index.js:63:32)\n at middleware (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\compose-middleware\lib\index.js:76:16)\n at C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\compose-middleware\lib\index.js:15:47\n at Layer.handle [as handle\_request] (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\express\lib\router\layer.js:95:5)\n at next (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\express\lib\router\route.js:137:13)”  
}  
POST /forest/actions/ajouter-un-contrat-d-immeuble/hooks/change?timezone=Europe%2FParis 500 37 - 7.295 ms  
[forest] 🌳🌳🌳 Error in smart action change hook: hook must be a function  
{  
“stack”: “Error: hook must be a function\n at SmartActionHookService.\_callee$ (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\dist\services\smart-action-hook-service.js:78:23)\n at tryCatch (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\regenerator-runtime\runtime.js:63:40)\n at Generator.invoke [as \_invoke] (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\regenerator-runtime\runtime.js:293:22)\n at Generator.next (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\regenerator-runtime\runtime.js:118:21)\n at asyncGeneratorStep (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\node\_modules\@babel\runtime\helpers\asyncToGenerator.js:3:24)\n at \_next (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\node\_modules\@babel\runtime\helpers\asyncToGenerator.js:25:9)\n at C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\node\_modules\@babel\runtime\helpers\asyncToGenerator.js:32:7\n at new Promise ()\n at SmartActionHookService. (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\node\_modules\@babel\runtime\helpers\asyncToGenerator.js:21:12)\n at SmartActionHookService.getResponse (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\dist\services\smart-action-hook-service.js:138:29)\n at \_callee2$ (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\dist\routes\actions.js:117:56)\n at tryCatch (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\regenerator-runtime\runtime.js:63:40)\n at Generator.invoke [as \_invoke] (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\regenerator-runtime\runtime.js:293:22)\n at Generator.next (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\regenerator-runtime\runtime.js:118:21)\n at asyncGeneratorStep (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\node\_modules\@babel\runtime\helpers\asyncToGenerator.js:3:24)\n at \_next (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\node\_modules\@babel\runtime\helpers\asyncToGenerator.js:25:9)\n at C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\node\_modules\@babel\runtime\helpers\asyncToGenerator.js:32:7\n at new Promise ()\n at C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\node\_modules\@babel\runtime\helpers\asyncToGenerator.js:21:12\n at C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\dist\routes\actions.js:144:24\n at Layer.handle [as handle\_request] (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\express\lib\router\layer.js:95:5)\n at  
next (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\express\lib\router\route.js:137:13)\n at dispatch (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\compose-middleware\lib\index.js:46:24)\n at next (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\compose-middleware\lib\index.js:51:24)\n at ipAuthorizer (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\dist\middlewares\ip-whitelist.js:25:12)\n at C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\dist\services\auth.js:61:10\n at dispatch (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\compose-middleware\lib\index.js:63:32)\n at next (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\compose-middleware\lib\index.js:51:24)\n at ensureAuthenticated (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\forest-express-sequelize\node\_modules\forest-express\dist\services\auth.js:31:10)\n at dispatch (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\compose-middleware\lib\index.js:63:32)\n at middleware (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\compose-middleware\lib\index.js:76:16)\n at C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\compose-middleware\lib\index.js:15:47\n at Layer.handle [as handle\_request] (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\express\lib\router\layer.js:95:5)\n at next (C:\DEV\git\sergic\syndic-one-rebirth\node\_modules\express\lib\router\route.js:137:13)”

## Context

- Project name: Sergic
- Team name: Gestion
- Environment name: development
- Agent (forest package) name & version: 7.12.3 to 8.5.14
- Database type: Postgre
- Recent changes made on your end if any: …

---

<div class="post-metadata">

**Author:** ![anon33050819](https://avatars.discourse-cdn.com/v4/letter/a/ac91a4/32.png) [@anon33050819](https://community.forestadmin.com/u/anon33050819)\
**Post date:** [July 17, 2023, 2:25pm UTC](https://community.forestadmin.com/t/smart-action-hooks-change-doesnt-work-when-upgrating-to-v8/6508/2 "2023-07-17T14:25:32Z")

</div>

Hi @Soufiane ,

I see you have had several issues since upgrading to V8, would you be available for a tech session.

Feel free to choose the slot that suits you =\> [Calendly - Salim Ameur](https://calendly.com/salim-forestadmin/30min)

Best,

---

<div class="post-metadata">

**Author:** ![anon7284711](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@anon7284711](https://community.forestadmin.com/u/anon7284711)\
**Post date:** [July 17, 2023, 2:32pm UTC](https://community.forestadmin.com/t/smart-action-hooks-change-doesnt-work-when-upgrating-to-v8/6508/3 "2023-07-17T14:32:01Z")

</div>

Hello @Soufiane,

You should be able to find all solutions when upgrading to v8 in [this note](https://docs.forestadmin.com/documentation/extra-help/maintain/upgrade-notes-sql-mongodb/upgrade-to-v8).

The issue you face is due to some breaking change that happened on Smart Actions, here is the [link](https://docs.forestadmin.com/documentation/extra-help/maintain/upgrade-notes-sql-mongodb/upgrade-to-v8#smart-actions) for the new procedure to follow.

Best regards,
