CODE.GS::onDriveItemsSelected - onItemsSelectedTrigger - not work as expected

132 views
Skip to first unread message

Paul Armstrong

unread,
Mar 21, 2022, 1:39:30 AM3/21/22
to Google Apps Script Community
Hi
I am trying to code a Google Workspace Add-On that responds to a Drive change event. As per this manifest (appscripti.json) configuration.

"onItemsSelectedTrigger": {
"runFunction": "onDriveItemsSelected"
}

I have my permission set up on the oauth consent screen and feel confident they are correct as the add-on already does lots of work with Drive. 

As per the manifest, I have a function with the signature of
function onDriveItemsSelected(event) {
}

But no matter what I code into the function I always get the following in the log file.
Debug CODE.GS::onDriveItemsSelected

This is a log output I have not coded. Any code I do have is ignored. 
The following code has no effect: 

function onDriveItemsSelected(event) {
console.error("onDriveItemsSelected");
console.log(event);
console.info(JSON.stringify(event));

var section = CardService.newCardSection();
var text = CardService.newTextParagraph()
.setText("Test");
text.addWidget(text);

var card = CardService.newCardBuilder()
.addSection(section);

return card.build();
}

The log files does say that the onDriveItemsSelected function is executed.
And, again, I get the log entry "CODE.GS::onDriveItemsSelected"

Thank you

Paul Armstrong

unread,
Mar 21, 2022, 3:33:58 AM3/21/22
to Google Apps Script Community
I renamed the function in both the manifest and the code to be on2DriveItemsSelected and things magically started to work. 
Go figure!?
It is like onDriveItemsSelected is a reserved name.

CBMServices Web

unread,
Mar 21, 2022, 1:43:31 PM3/21/22
to google-apps-sc...@googlegroups.com
Paul,

Out of curiosity, which triggers are you using for your add-on?

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/04b86bab-c239-41d9-90bc-153d69448d81n%40googlegroups.com.
Message has been deleted

Paul Armstrong

unread,
Mar 22, 2022, 4:58:29 PM3/22/22
to Google Apps Script Community
(My last post was the wrong manifest, so I deleted it; in case you saw it and were confused).

I am only using the drive trigger. Here is the manifest with company information redacted. 

{
"timeZone": "Pacific/Auckland",
"dependencies": {
"enabledAdvancedServices": [
{
"userSymbol": "Drive",
"serviceId": "drive",
"version": "v2"
},
{
"userSymbol": "AdminDirectory",
"serviceId": "admin",
"version": "directory_v1"
},
{
"userSymbol": "Sheets",
"serviceId": "sheets",
"version": "v4"
},
{
"userSymbol": "DriveActivity",
"serviceId": "driveactivity",
"version": "v2"
}
],
"libraries": [
{
"userSymbol": "LodashGS",
"libraryId": "...",
"version": "5"
}
]
},
"webapp": {
"access": "MYSELF",
"executeAs": "USER_DEPLOYING"
},
"exceptionLogging": "STACKDRIVER",
"oauthScopes": [
],
"urlFetchWhitelist": [
"https://..."
],
"runtimeVersion": "V8",
"addOns": {
"common": {
"name": "...",
"logoUrl": "...",
"layoutProperties": {
"primaryColor": "#61166d",
"secondaryColor": "#424242"
},
"homepageTrigger": {
"runFunction": "onHomePage",
"enabled": false
},
"universalActions": [
{
"label": "Feedback",
"openLink": "mailto:.."
}
],
"openLinkUrlPrefixes": [
"https://.."
]
},
"drive": {
"homepageTrigger": {
"runFunction": "onDriveHomePage",
"enabled": true
},
"onItemsSelectedTrigger": {
"runFunction": "on2DriveItemsSelected"
}
}
}
}
Reply all
Reply to author
Forward
0 new messages