S
S
Sergey Sokolov2017-09-06 21:40:55
Google Apps Script
Sergey Sokolov, 2017-09-06 21:40:55

How to allow Google Apps Script to send email to any Spreadsheet user?

A script has been made for one Google Spreadsheet. When some cells change, sends email to fixed addresses via MailApp.sendEmail()
The document was created by User-A.
The document is accessed by User-A, User-B and User-C. All with the right to make changes.
The script was created by user User-B. When he set up a trigger for launching the desired function when changing this document, there was a request for permissions, a warning about an unverified script and continuing at your own peril and risk only if you trust the developer. OK.

screenshots
8cf466d2a2774e10b484b2183354278b.jpgd0077747cac84293997add3271f33a89.jpgff1367abc65b48968de8e47ee63e29af.jpg9260fa8df68f48f2b074875287b7e3e6.jpg601606537314421db52816341bd411d5.jpgf52a3b6fd0074854b618ad2c51bb94c2.jpg

When cells are edited by this user, an email is sent.
When editing by others, it is not sent, an error is visible in the console
У вас отсутствует разрешение на вызов функции sendEmail (строка 13, файл Код)

How to make it so that only one user gives permission, and a letter is sent on his behalf, but the script works with sending mail for all users with access to the document?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ivanov, 2017-09-07
@sergiks

The description is not enough, the code is not visible, although you can already guess where the error is hiding. Separate concepts:
Judging by the description, User-B was authorized, and the rest of the users were not. Force these users to go through authorization, and they will have permission to run functions.
How to force users to log in is the developer's problem, not Google's. But, having no serious contradictions in technical terms, this approach is difficult to understand in practice. Examples of applications whose code can be the same up to a comma.
When developing a client-server application, you need to take care of multi-user access. It is necessary to develop a process and order of access, and only after that figure out how to implement it. For example,
Personally, it would be unpleasant for me that someone requires me to send some letters to no one knows where and why, surviving an already meager quota.
Review your application. What goals does it pursue? What have you already achieved? Is that how it works? Give an example code and the essence of the application.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question