0

When I run my script from within the editor it executes only once and everything works but if i call it from a web page or an excel add-in or any other place for that matter it sometimes runs multiple times until it reaches the 5 minute limit Google imposes. Is there a way to stop a script after its first run or a way to check whether it is already running.

Thx for any help.

Albertus
  • 911
  • 2
  • 10
  • 19
  • That's not normal behavior. It sounds like you've got faulty logic related to the handling of the event. When you test in the editor, are you simulating the events you'll receive from a `get`, and following it through? See [How can I test a trigger function in GAS?](http://stackoverflow.com/questions/16089041/how-can-i-test-a-trigger-function-in-gas). If that doesn't sort things out for you, please post your code - without it, it's unlikely you'll get an answer to a problem like this. – Mogsdad May 07 '13 at 12:22

1 Answers1

0

This seems to work :

var start = parseInt(UserProperties.getProperty('count'),10);
if (start == 0) 
{
   UserProperties.setProperty('count', 1)
   //do stuff
   UserProperties.setProperty('count', 0)
}
else if (start>0) 
{
  Logger.log("Script is still runnning");
}
Albertus
  • 911
  • 2
  • 10
  • 19
  • 1
    That's a weird usage of UserProperties and you may end up with concurrency issues anyway. It seems you're looking for the [Lock Services](https://developers.google.com/apps-script/reference/lock/). – Henrique G. Abreu May 07 '13 at 13:13