Created
July 27, 2018 08:47
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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