In my app for google spreadsheet I save some params in localStorage in one function. And in another function I need to retrieve them. Of course, I can create modeless dialog or sidebar, when will be my html code and js, but this second function only refresh current sheet, so I don't need UI. Also I know, that server side doesn't have access to localStorage.
Here is my abstract code:
server.gs
:
function menuItemClicked()
{
// when we click on item in addon menu, this called
// and load 'client.html'
}
function refreshCurrentSheet(params)
{
// called by 'client.html'
// do something else with params...
}
client.html
:
<script type="text/javascript">
google.script.run.refreshCurrentSheet( localStorage.getItem('var') );
</script>
I didn't find answer in API, how to do that(
Question: how can I load html and execute js without visible UI ?
P.S. Saving these params on server-side in cache is not a solution, because I often use and change them in client
You can use either Properties Service or Cache Service. Both provide localStorage functionality allowing you to store key value pairs (string type only). If you'd like to persist data between function calls, Cache is probably the best option
More on Cache Service https://developers.google.com/apps-script/reference/cache/
More on Properties Service https://developers.google.com/apps-script/reference/properties/