Search code examples
javascriptgoogle-appsgoogle-sheetsgoogle-apps-script

Google apps script: how to persist data in spreadsheet between different function calls?


In a Google spreadsheet using the Script Editor, I do function calls, but I am not quite sure if the best way to store persistant data (data that I will continue to use) is to use global variables (using objects, arrays, strings), or there is a better way to store data.

I don't want to use cells which could be another way.

Another question, is it possible to create (pseudo) classes in this environment? Best way?


Solution

  • Persistent data can be stored using the Class ScriptProperties:

    http://code.google.com/googleapps/appsscript/class_scriptproperties.html

    All values are stored as a string and will have to be converted back with the likes or parsInt or parseFloat when they are retrieved.

    JSON objects can also be stored in this manner.