# Not updating using GSheets and Script App

**URL:** <https://community.glideapps.com/t/not-updating-using-gsheets-and-script-app/59683>\
**Category:** Ask for Help\
**Created:** [March 25, 2023, 6:49pm UTC](https://community.glideapps.com/t/not-updating-using-gsheets-and-script-app/59683 "2023-03-25T18:49:34Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![E\_J\_E](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/e_j_e/32/29498_2.png) [@E\_J\_E](https://community.glideapps.com/u/E_J_E)\
**Post date:** [March 25, 2023, 6:49pm UTC](https://community.glideapps.com/t/not-updating-using-gsheets-and-script-app/59683/1 "2023-03-25T18:49:34Z")

</div>

Hello,  
Ive been trying to understand and find a solution to a problem ive been having since a few days:  
Ive added an =importhtml to my google sheet to have updated quotes from a specific website. By using this function, with an app script and a trigger, the imported html does not update though i does refresh. IF i try this same procedure on a new workbook, it does work.  
I am wondering if something conflicts when connected to glide. or if anyone else has had this issue when using an app script?  
thank you very much for your help.

---

<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:** [March 26, 2023, 12:39am UTC](https://community.glideapps.com/t/not-updating-using-gsheets-and-script-app/59683/2 "2023-03-26T00:39:27Z")

</div>

So do you mean the IMPORTHTML content does not refresh on the Google Sheets side?

I would suggest adding an unharmful param to your URL so it won’t be “cached”. Something like:

```auto
https://example.com/query?t=20230326

```

With 20230326 crafted from a “today” value. Once it updates, your IMPORTHTML will be forced to update as well.

---

<div class="post-metadata">

**Author:** ![E\_J\_E](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/e_j_e/32/29498_2.png) [@E\_J\_E](https://community.glideapps.com/u/E_J_E)\
**Post date:** [March 26, 2023, 2:03am UTC](https://community.glideapps.com/t/not-updating-using-gsheets-and-script-app/59683/3 "2023-03-26T02:03:56Z")

</div>

Thank you Thinh. I will try this parameter.  
So if i undertand you well i should add ‘/[query?t=20230326](https://example.com/query?t=20230326)’ meaning if my function is: '=ImportHTML(“[https://uk.investing.com/commodities/real-time-futures](https://uk.investing.com/commodities/real-time-futures)”,“table”,1)  
I should do the following: '=ImportHTML(“[https://uk.investing.com/commodities/real-time-futures](https://uk.investing.com/commodities/real-time-futures)/[query?t=20230326](https://example.com/query?t=20230326)”,“table”,1) this in the app script?

 ![image.png](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/3/2/32019e845f8a2c099bfb6b9b4925bef97c274263.jpeg)I will try as advised. thank u.

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [March 26, 2023, 7:10am UTC](https://community.glideapps.com/t/not-updating-using-gsheets-and-script-app/59683/4 "2023-03-26T07:10:26Z")

</div>

To use the suggestion from @ThinhDinh, you would have:

```auto
=ImportHTML(“https://uk.investing.com/commodities/real-time-futures?t=20230326”,“table”,1)

```

---

<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:** [March 26, 2023, 9:03am UTC](https://community.glideapps.com/t/not-updating-using-gsheets-and-script-app/59683/5 "2023-03-26T09:03:13Z")

</div>

Yes, but you should have a dynamic variable so that the "t’ value changes.

---

<div class="post-metadata">

**Author:** ![E\_J\_E](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/e_j_e/32/29498_2.png) [@E\_J\_E](https://community.glideapps.com/u/E_J_E)\
**Post date:** [March 27, 2023, 2:58pm UTC](https://community.glideapps.com/t/not-updating-using-gsheets-and-script-app/59683/6 "2023-03-27T14:58:24Z")

</div>

How can i set the ‘t’ variable to dynamic? Thank you

---

<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:** [March 27, 2023, 5:27pm UTC](https://community.glideapps.com/t/not-updating-using-gsheets-and-script-app/59683/8 "2023-03-27T17:27:18Z")

</div>

Hola!

You need to add a line to your code to get a dynamic value in _ **t** _, something like…

```auto
var value= (Math.random()*10000000).toFixed(); 

var myFormula='=ImportHTML(“https://uk.investing.com/commodities/real-time-futures?t=${value}”,“table”,1)'

```

_ **t** _ will range from 1-9,999,999 each time your code is executed and avoid using script’s cache

---

<div class="post-metadata">

**Author:** ![E\_J\_E](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/e_j_e/32/29498_2.png) [@E\_J\_E](https://community.glideapps.com/u/E_J_E)\
**Post date:** [March 27, 2023, 8:18pm UTC](https://community.glideapps.com/t/not-updating-using-gsheets-and-script-app/59683/9 "2023-03-27T20:18:44Z")

</div>

thank you Valero, will try adding that to the script. 👍

---

<div class="post-metadata">

**Author:** ![E\_J\_E](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/e_j_e/32/29498_2.png) [@E\_J\_E](https://community.glideapps.com/u/E_J_E)\
**Post date:** [March 27, 2023, 11:01pm UTC](https://community.glideapps.com/t/not-updating-using-gsheets-and-script-app/59683/10 "2023-03-27T23:01:22Z")

</div>

IT HAS BEEN SOLVED: Thank you all!!

So i leave this here just in case anyone has the same problem:

 ![image.png](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/6/8/686eb232a9470e9395c7c1b8578e4ea1c4f7f988.png)

to copy and paste:

function updateformula() {  
//Formula is located on Sheet7, in cell A2  
var myRange=SpreadsheetApp.getActiveSpreadsheet().getSheetByName(‘Sheet7’).getRange(‘B5’);  
var value= (Math.random()\*10000000).toFixed();  
var myformula=‘=ImportHTML(“[https://uk.investing.com/commodities/real-time-futures/?t=${value}](https://uk.investing.com/commodities/real-time-futures/?t=%24%7Bvalue%7D)”;“table”;1)’  
myRange.setFormula(‘’);  
SpreadsheetApp.flush();  
myRange.setFormula(myformula);  
//to show when the last time that this information was updated - add in the date/time to cell E1  
SpreadsheetApp.getActiveSpreadsheet().getSheetByName(‘Sheet7’).getRange(‘E1’).setValue(new Date());  
SpreadsheetApp.flush();  
return;  
}

(dont forget to add the trigger on timer)  
on GLIDE side you just work with google sheet using the following formula:

=ImportHTML(“[https://uk.investing.com/commodities/real-time-futures/?t=${value}](https://uk.investing.com/commodities/real-time-futures/?t=%24%7Bvalue%7D)”,“table”,1)  
Make sure to use the right sheet name on the script, in this case its sheet7.
