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?
- Do Google apps script has any feature to change the context/session? for example, though UserB is logged in;changing the session to UserA and performing the whole operations(Add/Modify/Delete) and then again changing back to UseB session?
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.