Reputation: 21
I am currently working with Google Apps Scripts in my project. But Facing issue with triggers. Scenario :
Two User - UserA - UserB
Logged in as UserA, created a google Spreadsheet and script to it. Also created few triggers. For e.g.
The Spreadsheet is shared to UserB with edit access. Now I am logged in as UserB.
Case 1: Trying to add a new trigger to the script Result => Trigger is created but only visible to UserB
Case 2: Modifying the existing trigger (created by UserA) Result => Cannot see the trigger created by UserA. Even if modify opreration happens without any error. no changes are applied to that trigger.
Case 3: Deleting the existing trigger (created by UserA) Result => Cannot see the trigger created by UserA. Even if Delete opreration happens without any error. no changes are applied to that trigger. I can still see it with UseA login.
My Qusetion:
1.Is there any way to -Modify the triggers by UserB which are created by UserA ? -Add a new trigger by UserB and is visible to UserA?
Below are my methods:
function createTimeDrivenTriggers() {
ScriptApp.newTrigger("assignEditUrls")
.timeBased()
.atHour(0)
.nearMinute(59)
.everyDays(1)
.create();
ScriptApp.newTrigger('processInputXML')
.timeBased()
.everyMinutes(5)
.create();
ScriptApp.newTrigger('assignFormResponseIDs')
.timeBased()
.everyMinutes(30)
.create();
ScriptApp.newTrigger('setSRHistoryColumn')
.timeBased()
.everyMinutes(1)
.create();
}
function createSpreadSheetTriggers() {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
ScriptApp.newTrigger("onOpen")
.forSpreadsheet(sheet)
.onOpen()
.create();
ScriptApp.newTrigger("sendEmailNotificationsOnFormSubmit")
.forSpreadsheet(sheet)
.onFormSubmit()
.create();
ScriptApp.newTrigger("notifyProductAssigneeOnFormSubmit")
.forSpreadsheet(sheet)
.onFormSubmit()
.create();
}
function deleteTrigger() {
// Loop over all triggers.
var allTriggers = ScriptApp.getProjectTriggers();
for (var i = 0; i < allTriggers.length; i++) {
ScriptApp.deleteTrigger(allTriggers[i]);
}
}
Any help will be appreciated. Thanks in advance.
Upvotes: 1
Views: 902
Reputation: 3355
You can't access the manual triggers which were created by others who have edited access to spreadsheet or google app script.
From Google App script documentation
When you collaborate on a project, any installable triggers that you create are not shared with those who have access to your project. If you need to have a consistent trigger setup for all collaborators, you can use the Script service to create triggers programmatically, at run time.
As mentioned in the documentation you can programmatically schedule the triggers.
Upvotes: 2