# Smart action field hook not triggering for array type

**URL:** <https://community.forestadmin.com/t/smart-action-field-hook-not-triggering-for-array-type/5370>\
**Category:** Help me!\
**Tags:** smart-action\
**Created:** [October 11, 2022, 9:21am UTC](https://community.forestadmin.com/t/smart-action-field-hook-not-triggering-for-array-type/5370 "2022-10-11T09:21:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![zakarias](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/zakarias/32/6313_2.png) [@zakarias](https://community.forestadmin.com/u/zakarias)\
**Post date:** [October 11, 2022, 9:21am UTC](https://community.forestadmin.com/t/smart-action-field-hook-not-triggering-for-array-type/5370/1 "2022-10-11T09:21:04Z")

</div>

Hi,

I am creating a smart action form and want to use the change hook for a field of type [“String”]. But the hook is never triggered on updates, only on the very first input. In other words, when I add the first element to the array, it triggers the hook, then never again afterward.

FYI, I tried changing the types of the field to “String” or “Number” and then the hook works as expected.

I am using forest-express-mongoose: v. 8.7.8

## Feature(s) impacted

[Using a smart action form](https://docs.forestadmin.com/documentation/reference-guide/actions/create-and-manage-smart-actions/use-a-smart-action-form)

## Observed behavior

The hook is only triggered 1 time when adding the first element to the array. After this, it is never triggered again, no matter how many elements I add/remove.

Smart action form:

```js
{
  name: "Test",
  type: "global",
  endpoint: "/forest/actions/test",
  fields: [
    {
      field: "test",
      type: ["String"],
      isRequired: true,
      defaultValue: [],
      hook: "onTestChange",
    },
  ],
  hooks: {
    change: {
      onTestChange: async ({ fields, request, changedField }) => {
        console.log("Hook triggered!");
        return fields;
      },
    },
  },
},

```

These are the only logs outputted (only once):

```sh
Hook triggered!
POST /forest/actions/test/hooks/change?timezone=Europe%2FStockholm 200 244 - 3.584 ms

```

## Expected behavior

Each time an element is added/removed, I expect the change hook to be triggered.

## Context

Project: PayAtt Internal Admin Portal  
Team: IT  
Environment: Development

---

<div class="post-metadata">

**Author:** ![Florian\_Gonzales](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/florian_gonzales/32/5541_2.png) [@Florian\_Gonzales](https://community.forestadmin.com/u/Florian_Gonzales)\
**Post date:** [October 11, 2022, 3:10pm UTC](https://community.forestadmin.com/t/smart-action-field-hook-not-triggering-for-array-type/5370/3 "2022-10-11T15:10:17Z")

</div>

Hello @zakarias ,

Thank you for your feedback, it is very important for us to have this information. Indeed I manage on my side to reproduce your problem, I have just added the resolution of this bug to the list of our tasks and we start to work on it. 🙏

Kind regards,

Florian

---

<div class="post-metadata">

**Author:** ![zakarias](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/zakarias/32/6313_2.png) [@zakarias](https://community.forestadmin.com/u/zakarias)\
**Post date:** [October 13, 2022, 7:39am UTC](https://community.forestadmin.com/t/smart-action-field-hook-not-triggering-for-array-type/5370/4 "2022-10-13T07:39:54Z")

</div>

Hello @Florian_Gonzales,

Thank you for your response. Sounds good, I’ll be waiting eagerly for a solution 🙂

Kind regards,  
Zakarias

---

<div class="post-metadata">

**Author:** ![Florian\_Gonzales](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/florian_gonzales/32/5541_2.png) [@Florian\_Gonzales](https://community.forestadmin.com/u/Florian_Gonzales)\
**Post date:** [October 18, 2022, 9:01am UTC](https://community.forestadmin.com/t/smart-action-field-hook-not-triggering-for-array-type/5370/5 "2022-10-18T09:01:16Z")

</div>

Hello @zakarias ,

The bug fix for your problem is normally live! The change hook trigger in the smart action should work correctly now, sorry for the wait. Please tell me if your problem is now well solved 🙏

Kind regards,

Florian

---

<div class="post-metadata">

**Author:** ![zakarias](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/zakarias/32/6313_2.png) [@zakarias](https://community.forestadmin.com/u/zakarias)\
**Post date:** [October 26, 2022, 8:41am UTC](https://community.forestadmin.com/t/smart-action-field-hook-not-triggering-for-array-type/5370/6 "2022-10-26T08:41:57Z")

</div>

Hi @Florian_Gonzales,

I’m sorry for the slow response, I was away for a week.

Unfortunately, I am still seeing the problem. I upgraded to use forest-express-mongoose@8.7.9.

Kind regards,  
Zakarias

---

<div class="post-metadata">

**Author:** ![Florian\_Gonzales](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/florian_gonzales/32/5541_2.png) [@Florian\_Gonzales](https://community.forestadmin.com/u/Florian_Gonzales)\
**Post date:** [October 28, 2022, 10:25am UTC](https://community.forestadmin.com/t/smart-action-field-hook-not-triggering-for-array-type/5370/7 "2022-10-28T10:25:26Z")

</div>

Hello @zakarias ,

Sorry for the inconvenience we had problems on the component related to this feature recently. A fix for the problem will be released on Monday, I will send you back at that time and your problem should be solved then !

Kind regards,

Florian

---

<div class="post-metadata">

**Author:** ![Florian\_Gonzales](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/florian_gonzales/32/5541_2.png) [@Florian\_Gonzales](https://community.forestadmin.com/u/Florian_Gonzales)\
**Post date:** [November 2, 2022, 1:23pm UTC](https://community.forestadmin.com/t/smart-action-field-hook-not-triggering-for-array-type/5370/8 "2022-11-02T13:23:13Z")

</div>

Hello @zakarias ,

We have deployed a patch that is supposed to solve your problem. If you could tell me if everything is working properly for you it would be great! 🙏

Kind regards,

Florian

---

<div class="post-metadata">

**Author:** ![zakarias](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/zakarias/32/6313_2.png) [@zakarias](https://community.forestadmin.com/u/zakarias)\
**Post date:** [November 2, 2022, 1:56pm UTC](https://community.forestadmin.com/t/smart-action-field-hook-not-triggering-for-array-type/5370/9 "2022-11-02T13:56:42Z")

</div>

Hello @Florian_Gonzales,

Everything works perfectly again. Thank you!

Kind regards,  
Zakarias
