Tamás
Tamás

Reputation: 91

Calling apps script function from drive UI

I just implemented a function which operates on a File object in Google Drive(*). Long story short: the function doSomething(file) { ... } exists (in a standalone Google Apps Script) and is well tested.

I want to call this from the Drive UI, e.g. using context menu -> Open With ... (but really any sensible means would be OK).

Is there a straightforward way to achieve this? I prefer not to go through 'registering an app in the Chrome store' whole shebang when all I need is a glorified macro for myself.

I just finished listening to https://www.youtube.com/watch?v=0HVJMIeb3aE which comes closest so far but it seems to skip the technical details of exactly what I need.

(*) There is a rather frustrating repetitive per-file workflow within my organization whereby one needs to switch all write accesses to read-only, then assign ownership to a given user then change your own rights to read-only.

Upvotes: 0

Views: 255

Answers (1)

Spencer Easton
Spencer Easton

Reputation: 5782

This can absolutely be done in Apps Script. There is a bit of set-up. That video you posted was the one I used to figure it out. When your app is attached to the drive ui your registered mime-types will have your app in the right-click menu.

I made a barebones framework that is highly commented about this process. It also shows how I handle the cases of being installed from the chrome store and called launched from chrome/chrome app launcher. You can make a copy of it here:

https://script.google.com/d/1nrwcxTjzysJl2DMSNB3BHyYfJLEbm02-ekusjUg4V9abzLZ3R_1Yqctj/edit?usp=sharing

*note: This assumes a bit of apps script familiarity. As the '13 IO videos were my first intro to apps script I'm fairly certain it is not that bad to get going.

Upvotes: 1

Related Questions