# Hooks change conditional triggering

**URL:** https://community.forestadmin.com/t/hooks-change-conditional-triggering/2391
**Category:** Help me!
**Created:** [April 29, 2021, 9:06am UTC](https://community.forestadmin.com/t/hooks-change-conditional-triggering/2391 "2021-04-29T09:06:08Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![JeremyV](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/jeremyv/32/1033_2.png) [@JeremyV](https://community.forestadmin.com/u/JeremyV)
#### Post date: [April 29, 2021, 9:06am UTC](https://community.forestadmin.com/t/hooks-change-conditional-triggering/2391/1 "2021-04-29T09:06:08Z")

</div>

I am using hooks change for the first time, it is great !

```javascript
{
    name: 'Ajouter un nouveau contrat de maintenance',
    type: 'single',
    fields: [{
      field: 'Recherche fournisseur',
      type: 'String'
    }, {
      field: 'Fournisseur',
      type: 'Enum',
      enums: []
    }],
    hooks: {
      change: {
        ['Recherche fournisseur']: ({ fields, record }) => {
          if (fields['Recherche fournisseur'].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'].value,
                siret: '',
                matricule: ''
              }
            }).then(res => {
              if (res.data && res.data.length > 0) {
                fields['Fournisseur'].enums = res.data.map(provider => `${provider.matricule} - ${provider.raison_sociale}`)
              }
              return fields;
            });
          }
          return fields;
        }
      }
    }
  }

```

As you can see, I trigger a GET whenever the user type in more than 2 letters. BUT the change event is triggered after a short time whenever a single letter is typed in, which cause the user to lose focus on the input field, which might be annoying for a slow typer.  
I’ve been trying to NOT return anything, or null, or an empty object {} to prevent the form fields reloading but so far I have an error each time.

Is there any way i can set the timeout before the change event triggering or condition the trigger event in a more efficient way ? Thank you.

---

<div class="post-metadata">

### Author: ![anon79585656](https://avatars.discourse-cdn.com/v4/letter/a/7ab992/32.png) [@anon79585656](https://community.forestadmin.com/u/anon79585656)
#### Post date: [April 29, 2021, 9:23am UTC](https://community.forestadmin.com/t/hooks-change-conditional-triggering/2391/2 "2021-04-29T09:23:21Z")

</div>

Hello @JeremyV,

I’m very sorry but I can’t find an easy workaround for this issue.

I agree that this behaviour is far from ideal and I will share your feedback with the team.

We will let you know when this is fixed.

---

<div class="post-metadata">

### Author: ![JeremyV](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/jeremyv/32/1033_2.png) [@JeremyV](https://community.forestadmin.com/u/JeremyV)
#### Post date: [April 29, 2021, 9:30am UTC](https://community.forestadmin.com/t/hooks-change-conditional-triggering/2391/3 "2021-04-29T09:30:11Z")

</div>

Thank you @anon79585656
