1

First of all I have spreadsheet with app script bundled to it.

  1. I have an api built in node.js and I am using drive api to create a copy of my spreadsheet.
  2. I share that file with a user for whom the copy was actually created and give him 'editor' permissions.
  3. When user opens shared spreadsheet, bundled script doesn't work. None of the triggers work (onEdit, onOpen..).

I also use sheets api in between to populate sheets with list of options (from db) but that doesn't matter now. That part works fine.

If I open original file bundled script works fine.

Thanks in advance for ur help.

Update - additional explanation (@Tanaike): If I create a copy directly on google drive, it works, even if one of my colleagues opens it.

Detailed explanation (node.js part):

  1. await drive.files.copy(params) - creates a copy of a spreadsheet, these are the params const params = { fileId: id, resource: { name: test }, supportsAllDrives: true, }
  2. await drive.permissions.create({ fileId: id, requestBody: { emailAddress: user.email, role: 'writer', type: 'user', }, })

This gives him writer (editor) permissions.

When that user opens this spreadsheet, apps script doesnt work. I can open it from Extensions -> apps script, but none of the triggers work (onEdit, onOpen..).

Note that I am using Google Drive API and Simple Triggers in the Apps Script. + Service account

  • When I tested your flow using `onEdit`, I confirmed that when the shared user can work `onEdit` for the copied Spreadsheet. Unfortunately, I cannot replicate your situation. I apologize for this. I did your flow. But I'm worried that I couldn't correctly replicate your situation. So, in order to correctly understand your situation, can I ask you about the detailed flow for correctly replicating your issue? By this, I would like to confirm it. – Tanaike Feb 03 '22 at 08:05
  • Although I'm not sure about your detailed situation, for example, when you had used the installable trigger, the script of the copied Spreadsheet has no installable trigger. Please be careful about this. – Tanaike Feb 03 '22 at 08:07
  • Thank you for replying and adding more information. From `Note that I am using Google Drive API and Simple Triggers in the Apps Script. + Service account`, now I could know that you used the service account. When the owner of the copied file is the service account, Google Apps Script cannot be used. This is the current specification. But there is a workaround. You can see the same question at https://stackoverflow.com/q/70367955 – Tanaike Feb 03 '22 at 11:26
  • By the way, I thought that your question is the same as https://stackoverflow.com/q/70367955 question. So I flagged it as a duplicated question. – Tanaike Feb 03 '22 at 11:26
  • @Tanaike is there a workaround for onOpen event? – Nemanja Ignjatovic Feb 03 '22 at 14:08
  • Thank you for replying. About `is there a workaround for onOpen event?`, unfortunately, in the current stage, I have no one. This is due to my poor skill. I deeply apologize for this. I would be grateful if you can forgive my poor skill. – Tanaike Feb 03 '22 at 23:52
  • @Tanaike no problem at all. Thank you very much for the answers above. – Nemanja Ignjatovic Feb 04 '22 at 07:40

0 Answers0