Google Script Error: You do not have permission to call openById

前端 未结 2 690
感动是毒
感动是毒 2021-01-14 15:11

I am trying to send a mail with attaching a file available in my google drive using following google scripts

var file=DriveApp.getFileById(\'1qZVK0UZ1jLbDdj1         


        
相关标签:
2条回答
  • 2021-01-14 15:34

    I ran into this same issue, but felt it was a little silly to have to use the FormResponses Sheet to get the submission event (I mean there's a trigger on the Form Apps Scripts for a reason, right?).

    All I had to do was to Remove and Re-add the trigger for From form --> On form submit. When I added it, challenged me for OAuth permissions to view and use my google drive.

    Immediately after this, I was able to run on a Forms Apps Script Submission trigger again.

    0 讨论(0)
  • 2021-01-14 15:39

    I found this when creating the script on the Form itself.

    To solve the problem first have you form responses sent to a spreadsheet.

    From you form go to Tools > Script editor... copy you script and delete any triggers you have set up there, you won't be needing this script anymore.

    Now click on View responses button in your form to open the spreadsheet.

    • Go to Tools > Script editor... (for the spreadsheet).
    • You should start with a blank project.
    • Delete anything in there and paste in your script.
    • Save and name you project.

    Now set up your triggers as normal. You will find the third drop down list of the new trigger has the option On form submit.

    Once your script is authorised any time the form is submitted the event will trigger and will have access to the DriveApp.

    Once you've tested and got it working I would go back to the form and delete the script project in there. I do that to keep things tidy and save confusion if I come to alter the script later and have forgotten which one is actually live.

    I don't know if there is a limitation with Google Forms that limits their access to Drive or something.

    0 讨论(0)
提交回复
热议问题