Solution:
In order to make sure the imported data updates periodically, you can set up an Apps Script time-driven trigger that will periodically execute a function (called myFunction
in the example below) that will:
Workflow:
- Click
Tools > Script editor
in order to open the script editor.
- Install the time-driven trigger. You can do that manually, following these steps, or programmatically, by copying this function to the script editor and executing it once:
function createTrigger() {
ScriptApp.newTrigger("myFunction")
.timeBased()
.everyMinutes(1) // Alternatively, set it to 5,10,15,30 or use .everyHours
.create()
}
Note: In this example, the function is set to run every minute; you can change that period by setting another value at .everyMinutes(1)
-1, 5, 10, 15, 30 are allowed, see everyMinutes(n)- or using everyHours(n) instead, that's up to you.
- Once the trigger is installed, a function called
myFunction
will run with the periodicity you have previously set. For example, if the formula is in cell A2
from Sheet1
:
function myFunction() {
const sheet = SpreadsheetApp.getActive().getSheetByName("Sheet1");
const cell = sheet.getRange("A2");
const formula = cell.getFormula();
cell.clearContent();
SpreadsheetApp.flush();
cell.setFormula(formula);
}
Related: