I want to create a map when google sheets document opened. So I'm using onOpen() function and create the map. Then I want to use this map in other functions. So I'm using in onOpen():
var documentProperties = PropertiesService.getDocumentProperties();
documentProperties.setProperty("map", map);
and trying to get it in my function:
var x = PropertiesService.getDocumentProperties().getProperty('map');
but x is {} and when I'm trying to x.get() it throws error PropertiesService.getDocumentProperties(...).getProperty(...).get is not a function
As I understand, PropertiesService can't store the map or I'm doing it wrong. So the question is: how can I create a map on startup and share it between functions.
And example:
var map = new Map();
maap.set("key1", "value");
maap.set("key2", "value");
documentProperties.setProperty("map", map);
var x = PropertiesService.getDocumentProperties().getProperty('map');
var y = PropertiesService.getDocumentProperties().getProperty('map').get('key1');
P.S. values in my map are maps too.