# Trigger Function

**URL:** <https://community.glideapps.com/t/trigger-function/12981>\
**Category:** Ask for Help\
**Created:** [July 23, 2020, 12:04pm UTC](https://community.glideapps.com/t/trigger-function/12981 "2020-07-23T12:04:25Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Khushi\_Puri](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/khushi_puri/32/3183_2.png) [@Khushi\_Puri](https://community.glideapps.com/u/Khushi_Puri)\
**Post date:** [July 23, 2020, 12:04pm UTC](https://community.glideapps.com/t/trigger-function/12981/1 "2020-07-23T12:04:25Z")

</div>

Please guys I need some help.  
I am new here. I have created a COVID 19 Tracker app  
[https://letstrackcorona.glideapp.io/](https://letstrackcorona.glideapp.io/).  
I have to edit it everyday, please can anyone tell me about trigger function so that my sheet is updated automatically after some hours.

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [July 23, 2020, 1:28pm UTC](https://community.glideapps.com/t/trigger-function/12981/2 "2020-07-23T13:28:54Z")

</div>

What functions do you have in your sheet?

---

<div class="post-metadata">

**Author:** ![Khushi\_Puri](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/khushi_puri/32/3183_2.png) [@Khushi\_Puri](https://community.glideapps.com/u/Khushi_Puri)\
**Post date:** [July 24, 2020, 3:23am UTC](https://community.glideapps.com/t/trigger-function/12981/3 "2020-07-24T03:23:05Z")

</div>

IMPORTHTML is the function I have used.

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [July 24, 2020, 3:34am UTC](https://community.glideapps.com/t/trigger-function/12981/4 "2020-07-24T03:34:37Z")

</div>

According to Google’s official support, IMPORTHTML recalculates every 1 hour.

Functions that pull data from outside the spreadsheet recalculate at the following times:

- **ImportRange:** 30 minutes
- **ImportHtml, ImportFeed, ImportData, ImportXml:** 1 hour
- **GoogleFinance:** may be delayed up to 20 minutes

Reference: [https://support.google.com/docs/answer/58515?hl=en](https://support.google.com/docs/answer/58515?hl=en)

If you want a script to trigger it, the script here might be fine.

> <https://stackoverflow.com/questions/33643517/refresh-importhtml>

---

<div class="post-metadata">

**Author:** ![Khushi\_Puri](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/khushi_puri/32/3183_2.png) [@Khushi\_Puri](https://community.glideapps.com/u/Khushi_Puri)\
**Post date:** [July 24, 2020, 7:49am UTC](https://community.glideapps.com/t/trigger-function/12981/5 "2020-07-24T07:49:54Z")

</div>

In my case, it does not update, please help. It does not refersh automatically. I am a beginner so please tell should I paste the code in google script? Thanks in advance

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [July 24, 2020, 8:17am UTC](https://community.glideapps.com/t/trigger-function/12981/6 "2020-07-24T08:17:39Z")

</div>

Does it recalculate when you open the Sheets?

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [July 24, 2020, 1:02pm UTC](https://community.glideapps.com/t/trigger-function/12981/7 "2020-07-24T13:02:47Z")

</div>

That would be my question too. Is it the sheet not updating or the app not updating? Free apps will only pull updates from ImportHTML if you are potentially making data changes through the app to cause it to sync, or you upgrade to Pro and turn on Background Refresh. Google will not send ImportHTML updates to Glide automatically.

---

<div class="post-metadata">

**Author:** ![Khushi\_Puri](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/khushi_puri/32/3183_2.png) [@Khushi\_Puri](https://community.glideapps.com/u/Khushi_Puri)\
**Post date:** [July 24, 2020, 3:39pm UTC](https://community.glideapps.com/t/trigger-function/12981/8 "2020-07-24T15:39:04Z")

</div>

No, not at all

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [July 24, 2020, 3:40pm UTC](https://community.glideapps.com/t/trigger-function/12981/9 "2020-07-24T15:40:07Z")

</div>

Does it recalculate if you delete the content of the cell and undo that action immediately?

---

<div class="post-metadata">

**Author:** ![Khushi\_Puri](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/khushi_puri/32/3183_2.png) [@Khushi\_Puri](https://community.glideapps.com/u/Khushi_Puri)\
**Post date:** [July 24, 2020, 3:40pm UTC](https://community.glideapps.com/t/trigger-function/12981/10 "2020-07-24T15:40:38Z")

</div>

Yeah that is a major problem for me. As it is covid 19 tracker app, I need to again do IMPORTHTTML daily so as to update the tables

---

<div class="post-metadata">

**Author:** ![Khushi\_Puri](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/khushi_puri/32/3183_2.png) [@Khushi\_Puri](https://community.glideapps.com/u/Khushi_Puri)\
**Post date:** [July 26, 2020, 7:07am UTC](https://community.glideapps.com/t/trigger-function/12981/11 "2020-07-26T07:07:47Z")

</div>

When I delete the URL and again paste it there, then the table updates or recalculates.

---

<div class="post-metadata">

**Author:** ![gvalero](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gvalero/32/1037_2.png) [@gvalero](https://community.glideapps.com/u/gvalero)\
**Post date:** [July 26, 2020, 2:37pm UTC](https://community.glideapps.com/t/trigger-function/12981/12 "2020-07-26T14:37:37Z")

</div>

of course @Khushi_Puri, you need a script!

Use what I use on my Covid-19 APP too, it works fine:

```
function Actualizar() {
 // Se ejecuta cada 1 hora (it's fired each hour)
 var sheetName = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(" YOUR_TAB "); 
 var queryString = Math.random(); 
 var cellFunction = '=IMPORTHTML(" YOUR_LINK "; "table";1 )'; 
 sheetName.getRange('A1').setValue(cellFunction); 
  }

```

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/2X/5/53da15c6541091b5fb9777111b37483362439b45.png)

The function _Math.random()_ is to create a new value in spreadsheet and avoid to use/retrieve data from cache memory in every execution.

Don´t forget to create the script’s Trigger based on Time (1 hour) of course! 🥴

Saludos!

---

<div class="post-metadata">

**Author:** ![Khushi\_Puri](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/khushi_puri/32/3183_2.png) [@Khushi\_Puri](https://community.glideapps.com/u/Khushi_Puri)\
**Post date:** [July 27, 2020, 3:54am UTC](https://community.glideapps.com/t/trigger-function/12981/13 "2020-07-27T03:54:46Z")

</div>

Thank you so much 😌 😇  
I’ll definitely try this out today and inform you.  
Have a good day
