Fredy Sandoval
Fredy Sandoval

Reputation: 1

Modify Google Apps Script Global Variable

I've been searching for a solution to this problem for hours, maybe I've been reading wrong.

What I basically need is to modify a global variable content, what I've read on this article is that I have to set a property and then I could modify it, but I've been unable to make it work, I keep getting the first property I set.

The first thing I do is set a Property on the top of my script and it does save the Url I'm setting

var scriptProp = PropertiesService.getScriptProperties();
scriptProp.setProperty("sheetsUrl","https://**Url1**");  

Next, I try to modify its content on another function

function myFunction(user){
  if(user == "Fredy"){
    var scriptProp = PropertiesService.getScriptProperties();
    scriptProp.setProperty("sheetsUrl","https://**Url2**");
  }
}

But once I try to use this variable after "modifying its content", I keep getting the original Url1.

If anyone knows how to solve this I would highly appreciate it. Thanks in advance!

Upvotes: 0

Views: 168

Answers (1)

Maciek
Maciek

Reputation: 131

You have a typo. You are modifying two different variables
One named "sheetsUrl" and the other named "sheetUrl"

Upvotes: 1

Related Questions