I have the following code that builds buttons in a Workspace Add-On.
function createCard(text) {
var buttonSet = CardService.newButtonSet()
.addButton(createButton('doStuff','Do Stuff'));
var section = CardService.newCardSection()
.addWidget(buttonSet);
var card = CardService.newCardBuilder()
.addSection(section);
return card.build();
}
function createButton(functionName, text) {
var action = CardService.newAction()
.setFunctionName(functionName);
var button = CardService.newTextButton()
.setText(text)
.setOnClickAction(action)
.setTextButtonStyle(CardService.TextButtonStyle.FILLED);
return button;
}
function doStuff() {
// Heavy work on Google Doc
}
The doStuff()
function I previously made in Apps Script takes normally 5 minutes to run, and fits in the Google Apps Script quota, but when I copied it into the Workspace Add-On it gives Error with the add-on. Run time error. Exceeded maximum execution time
, so it needs to fit into the Card Service quota (45 seconds).
I noticed that, in the standalone Script, the execution log differs from an add-on trigger or an “Unknown” trigger (when I run it normally).
How can I call the "doStuff()"
function as “Unknown” so it uses the 6 minutes script runtime quota?