1

I am running a script in google sheets script editor, to trigger the script I use onChange in the Current project's triggers, using specific function -> From Spreadsheet -> On change.

Important to mention that I use the sheet with 3 more members that have edit permission who change time to time the data, I built the script and activate the trigger.

When I change anything in the sheet I get alerted (the trigger were on) but when other member changes the data the trigger doesn't work.

What have I missed here?

Thanks.

1 Answer 1

1

Everyone needs a trigger

You can add the trigger management into the program so that they have the triggers in their projects too. The isTrigger() function insures that you only create one trigger for each instance. You find the documentation here.

function myTriggerSetup() 
{
  if(!isTrigger('functionName'))
  {
    ScriptApp.newTrigger('functionName').forSpreadsheet('Spreadsheet').onChange().create();  
  }
}

function isTrigger(funcName)
{
  var r=false;
  if(funcName)
  {
    var allTriggers=ScriptApp.getProjectTriggers();
    var allHandlers=[];
    for(var i=0;i<allTriggers.length;i++)
    {
      allHandlers.push(allTriggers[i].getHandlerFunction());
    }
    if(allHandlers.indexOf(funcName)>-1)
    {
      r=true;
    }
  }
  return r;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.