-1

I am importing JSON data to Google Sheets using this solution (https://blog.fastfedora.com/projects/import-json).

It is vital that this data is accurate all the time, however, I have noticed that the data provided through this function lags behind the actual API feeds.

The issue can be sorted if I delete and Ctrl+Z, but obviously I am not available 24/7 to constantly do that :).

A solution I have is that in the cells with the IMPORTJSON function, I have placed the following before it: IF(A1=1,"",IMPORTJSON....

So if 1 is entered in A1, everything is deleted, and once the 1 is deleted, the feeds refresh with the correct data.

Again the issue is that I have to manually enter this 1. I would like to create a method of this one is entered automatically. Like every minute or five minutes.

How do I go about creating this time triggering cell?

player0
  • 124,011
  • 12
  • 67
  • 124
Dan
  • 105
  • 1
  • 6

1 Answers1

0
function updateCell() {
  var range = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Name of Sheet").getRange("A1");
  range.clear({contentsOnly: true});
  range.setValue(1);
}

And set that function to trigger on a timer every x minutes.

See the documentation for further information if you need finer revisions.

sinaraheneba
  • 781
  • 4
  • 18
  • Glad it works; if you still have issues, you might need to use [`flush()`](https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app#flush()) between clearing and setting the value; see also [this question](https://stackoverflow.com/questions/41175326/why-do-we-use-spreadsheetapp-flush) – sinaraheneba Jun 08 '19 at 12:18