Reputation: 198
I am making a bunch of calls to a database using UrlFetchApp.fetch. When I embed the spreadsheet all the data looks good while I still have the google spreadsheet open in the browser. But when I close the spreadsheet in the browser and then look at it in the embedded page, all the cells appear as "Thinking...". If I open the spreadsheet again through GDrive all the cells reload again. But every time I close it, the embedded sheet goes back to only displaying "Thinking...".
Does the sheet not maintain the data retrieved by functions when it is not open? Any way around this?
EDIT: sample function
function count(term, date){
var randnumber = Math.random()*10000;
Utilities.sleep(randnumber);
var response = UrlFetchApp.fetch("http://url");
var doc = Xml.parse(response.getContentText());
var topElement = doc.getElement();
var count = topElement.getElement("Count");
var countValue = count.getText();
var reference = countValue;
return reference;
}
Removing utilities.sleep() does not help
Upvotes: 0
Views: 442
Reputation: 198
Ok well here is a solution that doesn't really solve the problem:
I was embedding the widget, but if you embed the actual spreadsheet with this it will work:
<iframe src="https://docs.google.com/spreadsheet/ccc?key=KEYHERE&hl=en&ui=2&rm=minimal#gid=#" frameborder="0" width="whatever" height="whatever"></iframe>
I also cached the data so I don't hit limits.
I would rather show the widget (or list view so anyone can sort) instead because it removes the column/row letters, so I would still like to know why the widget won't display values using this function. But this will do for now.
Upvotes: 0