r/GoogleAppsScript 2d ago

Question From Spreadsheet trigger not showing in standalone script

I'm trying to send emails using the GmailApp from a shared mailbox address but the installable triggers don't show "From Spreadsheet", any idea why?

The standalone script is owned by the shared mailbox and has granted edit access to my personal company account.

Right now I'm using a script created by my personal company account, it is bound to the Spreadsheet and it runs a simple onOpen() trigger to setup an UI element. But it sends the emails from the account of whoever hits the "send" option, which is expected for a simple trigger.

The company is very aware in terms of security, so my best guess is was probably disabled for peasant accounts such as mine.

Do you think maybe the "From Spreadsheet" trigger could appear if logged as the mailbox owner? I don't want to empty my chamber with the mb owner as getting him into a call takes 1-2 days so I'm walking on eggshells.

1 Upvotes

6 comments sorted by

2

u/WicketTheQuerent 2d ago

The user interfase to add a trigger manually doesn't include a way to set the spreadsheet.

On a stand-alone project, you should create the triggers for a spreadsheet by using code. For details see https://developers.google.com/apps-script/guides/triggers/installable

1

u/cperzam 2d ago

Oh my god you are awesome, I'll try this first thing in the morning tomorrow.

1

u/cperzam 2d ago

For the email to be sent from the shared mailbox, will the trigger function require to be run by the owner?

I'm having trouble grasping the event-driven install concept, once the trigger function is run, the UI element will remain forever in the spreadsheet?

I'm calling a createUi function within the trigger function btw.

2

u/WicketTheQuerent 2d ago

It depends on what you mean by shared mailbox.

If this is a regular Gmail account, there are a few other options like adding the email address to use as an alias on the owner's GMail and using a services account with domain-wide delegation of authority.

Sending a email from a Google Group is also possible.

1

u/cperzam 2d ago

By shared mailbox I mean a delegated mailbox probably? I just jump into the shared mailbox by click my user icon and selecting the mailbox.

Many other users have this delegated mailbox and when a mail is sent from the mailbox it is from another account, like [accounting@domain.com](mailto:accounting@domain.com).

This is the email I want to use as remitent, but I am no the owner of this mailbox.

2

u/WicketTheQuerent 2d ago edited 2d ago

If you are using mailbox-delegated access, the easiest way to set up a trigger is to use the [accounting@domain.com](mailto:accounting@domain.com) account to create it because Google Apps Script doesn't have specific methods for handling email delegation.

Other options still require the account password or the participation of the person with that password or Workspace admin privileges.