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 splitName() { | |
| var name = 'SMITH, Johnny (John) (234567891) (sss12) - BA Archaeology'; | |
| // separate name out via: () , | |
| var string = name.split(/[(),]+/); | |
| Logger.log(string); | |
| // extract the necessary parts below | |
| var surname = string[0]; |
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 getFolders() { | |
| // ID of Parent folder | |
| var parentFolder = '1-SEFiD8rzNYj9f4N9xvXLLd8jl4p99is'; | |
| // get sub-folders | |
| var subFolders = DriveApp.getFolderById(parentFolder).getFolders(); | |
| // cycle through each sub-folder and get relevant details | |
| while (subFolders.hasNext()) { |
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 getAttachmentSize() { | |
| // get Gmail Inbox Label where emails are stored | |
| var label = GmailApp.getUserLabelByName('checkme'); | |
| // get an array of threads - currently limits to first 10 in inbox label | |
| var threads = label.getThreads(0,10); | |
| var numThreads = threads.length; | |
| // loop through threads ******************************************************************* |
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 logEvent(action) { | |
| // get the user running the script | |
| var theUser = Session.getActiveUser().getEmail(); | |
| // get the relevant spreadsheet to output log details | |
| var ss = SpreadsheetApp.getActiveSpreadsheet(); | |
| var logSheet = ss.getSheetByName('Log'); | |
| // create and format a timestamp |
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 getScriptTimeZone() { | |
| // get script time zone of location where being run | |
| var timeZone = Session.getScriptTimeZone(); | |
| // create a new date variable | |
| var newDate = new Date(); | |
| // format the new date variable as required | |
| var niceDate = Utilities.formatDate(newDate, timeZone, "dd_MM_YYYY HH:mm:ss"); |
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 getFolders() { | |
| // ID of Parent folder | |
| var parentFolder = '1Nspvl8NOssSiPg1l4yWfA8Dhym-J_rvl'; | |
| // get sub-folders | |
| var subFolders = DriveApp.getFolderById(parentFolder).getFolders(); | |
| // cycle through each sub-folder and get relevant details | |
| while (subFolders.hasNext()) { |
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 getContextualAddOn(event) { | |
| //make a card | |
| var card = CardService.newCardBuilder(); | |
| //make a card section | |
| var section = CardService.newCardSection(); | |
| //make a text input widget and add to the section | |
| var inputWidget = CardService.newTextInput().setFieldName('userId').setTitle('Enter username here'); | |
| section.addWidget(inputWidget); |
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 getUserInfo(e) { | |
| //get user id from event data | |
| var userId = e.formInput['userId']; | |
| Logger.log('Inputted username is: ' + userId); | |
| //check if entered username is not blank before proceeeding | |
| if (userId != '') { | |
| //call function to get the name + folderID for the user | |
| var details = getDetails(userId); |
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 getDetails(userId) { | |
| //get spreadsheet data from Global variable in 'spreadsheetID.gs' | |
| var ss = SpreadsheetApp.openById(ssId); | |
| var dataSheet = ss.getSheetByName('data'); | |
| var list = dataSheet.getDataRange().getValues(); | |
| //reset variables for loop | |
| var folderId = ''; | |
| var forename=''; |
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
| //called when errorCode = 0 | |
| function showCard0(userId, forename, surname, folderID) { | |
| //make a new card | |
| var card0 = CardService.newCardBuilder(); | |
| //create a card section for found name and username | |
| var section0_1 = CardService.newCardSection(); | |
| var cardUserId = CardService.newTextParagraph().setText('Username is: ' + userId); | |
| section0_1.addWidget(cardUserId); |