Skip to content

Instantly share code, notes, and snippets.

@eojji
Created July 27, 2018 08:47
Show Gist options
  • Save eojji/336e8906217e9453e4574e4b1d4e615b to your computer and use it in GitHub Desktop.
Save eojji/336e8906217e9453e4574e4b1d4e615b to your computer and use it in GitHub Desktop.
Search for Files and Team Drives, drive 15 - Google App Maker https://cafe.naver.com/eojji/349
function onDropdownAttach(widget) {
var props = app.currentPage.properties;
google.script.run.withSuccessHandler( function(list) {
if(list && list.length > 1) {
var listLength = list.length;
for(var i = 0; i < listLength; i++) {
var drive = list[i];
if (drive.id == props.TeamDriveId) {
widget.value = drive.id;
}
widget.options.push(drive.id);
widget.names.push(drive.name);
}
}
}).getHtmlSelectTeamDriveList();
}
function getHtmlSelectTeamDriveList() {
var myDriveId = DriveApp.getRootFolder().getId();
var drive = {
id: myDriveId,
name: 'My Drive'
};
var list = [drive];
var pageToken;
var optionalArgs = {
maxResults : 100,
pageToken : pageToken
};
var teamDriveList = Drive.Teamdrives.list(optionalArgs);
if (!teamDriveList || !teamDriveList.items || teamDriveList.items.length <= 0) {
return list;
}
for (var i = 0; i < teamDriveList.items.length; i++) {
var teamDrive = teamDriveList.items[i];
drive = {
id: teamDrive.id,
name: teamDrive.name
};
list.push(drive);
}
return list;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment