Brandon
Brandon

Reputation: 117

How to force a refesh on =importdata()?

My script previously used to work, however, I noticed recently that when I have this script active with a 5-minute interval trigger, it does not work. However, when I run the script it will load the data but it won't be updated data. It will actually only update the data when I delete the script, and then delete the function and re-paste it. :

function allergen()
{
SpreadsheetApp.getActive().getRange('Backend Data!H2').setValue('=importdata("https://app.periscopedata.com/api/company_name/chart/csv/cd30345f-08fe-808a-93cc-7e32a19353f4")')
}

Upvotes: 0

Views: 4229

Answers (2)

sports
sports

Reputation: 8147

I solved (or managed) like this:

  1. The importdata cell should end with ?v=" & some_cell_address)
    That is: an arbitrary querystring (I used "v" as "version") pointing to a cell address (eg. G2)

  2. Each time I want to force a refresh, I will increase the cell number (eg. 1, 2, 3, 4,...), a.k.a "version"

Forcing refresh

In the above example, if I want to force a refresh, I will change G2 from 2 to 3.
Next time I will change it from 3 to 4, etc...

Upvotes: 0

SputnikDrunk2
SputnikDrunk2

Reputation: 4038

You can refer to the answer from Google sheets importData, importRange speed / interval - ways to improve it?

Additionally, you can also check this other method from this post about enforcing a refresh to IMPORTDATA function at a certain interval.

Upvotes: 1

Related Questions