1
votes

I have a Google Sheet with the OnEdit() function on the sheet script. Also, this script imports a library which is another AppScript with some functions on it. It works perfectly when I'm using the sheet, whenever I edit it, the OnEdit triggers without any problems. But, because I shared this sheet with other people when they edit the sheet, the OnEdit does not trigger. It was working for all the users before I imported the library. After that, the OnEdit just works for me. I know that the problem is because the library is only shared with me, but the thing is that the functions inside the library work just fine with all the users. The only thing that does not work for all, is the OnEdit. I would like to find a solution to that because I cannot share the library with all the users who have access to the sheet. The onEdit just writes in a cell value, that's all the code it has.

I tried the OnEdit in a shared sheet and works perfectly for all. When I add a library, the onEdit works only for me.

function onEdit(e) {
  var logSheet = SpreadsheetApp.getActive().getSheetByName('test');
  logSheet.appendRow(['You edit']);
}
2

2 Answers

0
votes

If the other users do not have permission to access the library, there could be an issue with them using its functions. I believe your issue relates to creating the triggers through the integrated tool for it in the project. According to the Documentation on sharing:

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. For more information, see Managing Triggers Programmatically.

This could be the trigger only occurs with the user that created it (since it does not work on your test users).

Link to the documentation: https://developers.google.com/apps-script/guides/collaborating

-1
votes

I had the same issue. If you create an Installable Trigger that triggers your "onEdit" function, it will resolve your issue. You don't even need to share the library with anyone.