0

I have created 1 google app script project. which sends me an email every morning with schedule and tasks.

  • It has .gs script
  • And a trigger to execute everyday

If I want to share this with other users, haw can I share with them? Do I need to share the code and trigger or is there any good way to share apps script.

Gaurav
  • 3,615
  • 2
  • 27
  • 50
  • What do you mean by"share"? – Kos Oct 19 '21 at 09:52
  • @Kos share means allow other users to use script with their google account – Gaurav Oct 19 '21 at 10:10
  • well there a lot of ways to distribute apps script, and you probably can find this information in google. If you want to find solutions specifically for your case, you need to add more details to your post. Why do you want send your schedule and tasks to other users? – Kos Oct 19 '21 at 10:30
  • Thanks for response @Kos My main concern was related to trigger, if i distribute as webapp then triggers will be executed or not. – Gaurav Oct 19 '21 at 10:40
  • 1
    You cannot have triggers in web app, only in addon, see https://developers.google.com/apps-script/guides/triggers#restrictions also check https://stackoverflow.com/questions/32307856/install-trigger-on-script-created-from-google-webapp – Kos Oct 19 '21 at 10:54
  • 1
    @Kos Technically, both `doGet` and `doPost` are triggers and webapp can install any triggers freely. Simple triggers are not triggered due to the way, web app operates. – TheMaster Oct 19 '21 at 11:28

2 Answers2

4

These are the currently available methods to distribute:

  • Add on

    • Published add ons are very useful in distributing the functionality of the script with many users
    • Unpublished add ons can be shared directly by sharing the script. They have a lot of restrictions.
    • Simple triggers(like onOpen) are triggered automaticallyref.
    • Installable Triggers(like onChange) are managed by the script per user
  • Library

    • Users need at least read access to the script
    • Triggers are not shared
    • End users still need to create their own apps script, which accesses the library
  • Web app:

    • Variety of distribution options
    • If you don't want to share source code, you don't have to, but the web app should be published to run as yourself and should be accessible to "anyone"
    • Triggers are managed by the script. Installable triggers can be created per user. But simple triggers cannot be triggered "directly" from a http GET/POST. However, simple triggers are triggered in the project itself that is bound to a document(say, Google sheets)
    • End users still need to create their own apps script, which accesses the web app using HTTP requests GET or POST
  • ?:

    • This is mostly used to run your script as yourself without accessing the code editor, but can also be used to distribute if both the calling project and the target project uses the same GCP

Under most circumstances, you'll be restricted to less than 100 end users, except in case of published add ons or web apps(set to execute as the end user)

TheMaster
  • 45,448
  • 6
  • 62
  • 85
1

You can publish the script as a web app and set the app to execute as the authenticated user.

When your users launch the web app, they would authenticate the app with their own Google account credentials and the triggers would be added to their account.

With this approach, there's no need to create the script's source code with your users.

Amit Agarwal
  • 10,910
  • 1
  • 32
  • 43
  • will the existing trigger get copied for the user ? And thank you so much got a great source of learning from your profile https://www.labnol.org/ – Gaurav Oct 19 '21 at 10:11
  • @Gaurav - once the user enters your web app and authorizes the app with their Google account, you can call the trigger creation function from the doGet method of your script. That will automatically create the trigger in the user's account as soon as they authorize your app. – Amit Agarwal Oct 19 '21 at 18:37