-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
Description
Expected Behavior
It'd be nice if we could simply do something like CommonApp.getUi().alert(message)
, with CommonApp
having common features shared across different app types.
Actual Behavior
I find I have to create a helper function which returns DocumentApp || SpreadsheetApp || SlidesApp || FormApp
, so that I can do things like app().someFunctionIUseALotButInDifferentApps()
. For example, app().getUi().alert(message)
to show a dialog popup message like in this alert()
example:
function alert(message) {
app().getUi().alert(message);
}
function app() {
// DocumentApp accesses the current Google Doc.
// If you use this code in an app type not listed below, you can change this return line to another app type:
return DocumentApp || SpreadsheetApp || SlidesApp || FormApp; // || SomeOtherAppType
}
Questions
- Is there a common class that
DocumentApp
,SpreadsheetApp
,SlidesApp
,FormApp
, etc. already inherit from that's already in the public API? - If not, could it be exposed for use? Like using a
CommonApp
object instead of copy-pasting anapp()
helper function? I understand this might be by design, or might not be a priority use case (in which case I can just continue doing a simple copy-and-paste of the helper function, or just use the non-generic "...App" object specific to the current app type). - Otherwise, maybe an example helper function could be added to the examples folder? If there's interest, I could work on that. I think my example might be missing a few app types. If this is not a priority, no worries.