How to define global variable in Google Apps Script

后端 未结 6 2054
梦如初夏
梦如初夏 2020-11-30 03:23

I see most examples from Google is they use only functions in a single giant script.

e.g. https://developers.google.com/apps-script/quickstart/macros

But in

6条回答
  •  庸人自扰
    2020-11-30 04:28

    You might be better off using the Properties Service as you can use these as a kind of persistent global variable.

    click 'file > project properties > project properties' to set a key value, or you can use

    PropertiesService.getScriptProperties().setProperty('mykey', 'myvalue');
    

    The data can be retrieved with

    var myvalue = PropertiesService.getScriptProperties().getProperty('mykey');

提交回复
热议问题