You won’t like this: global variables in GAS are static – you can’t update them and expect them to retain their values. I, too, googled this for hours.
You can use CacheService
or ScriptDB
as possible storage for this sort of problem. CacheService
is quick and easy to use, but limited because the cache will expire eventually. I haven’t tried ScriptDB