Last active
December 17, 2020 23:01
-
-
Save zoracon/819f7fa0d5b25ff48aa9df0b040b8fbc to your computer and use it in GitHub Desktop.
Google Apps Script Note Generator from Sheets
This file contains 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 createNotesDoc() { | |
var sheet = SpreadsheetApp.getActiveSheet(); | |
var data = sheet.getDataRange().getValues(); | |
var lastrow = data.length - 1; | |
// Static data | |
var date = data[lastrow][0]; | |
var name = data[lastrow][1]; | |
var attendees = data[lastrow][2]; | |
var zoomLink = data[lastrow][3]; | |
var zoomID = data[lastrow][4]; | |
var zoomPass = data[lastrow][5]; | |
var doc = DocumentApp.create(name.toString()); | |
var body = doc.getBody(); | |
var style = {}; | |
style[DocumentApp.Attribute.FONT_SIZE] = 16; | |
body.appendParagraph('Date: ' + date).setAttributes(style); | |
body.insertParagraph(0, doc.getName()) | |
.setHeading(DocumentApp.ParagraphHeading.HEADING1); | |
//Static data | |
body.appendParagraph('Attendees: ' + attendees).setAttributes(style); | |
body.appendPageBreak(); | |
body.appendParagraph('Zoom Link: ' + zoomLink).setAttributes(style); | |
body.appendPageBreak(); | |
body.appendParagraph('Zoom ID: ' + zoomID).setAttributes(style); | |
body.appendPageBreak(); | |
body.appendParagraph('Zoom Pass: ' + zoomPass).setAttributes(style); | |
var files = DriveApp.getFilesByName(doc.getName()); | |
while (files.hasNext()) { | |
// Static | |
var folders = DriveApp.getFoldersByName('Folder Name'); | |
while (folders.hasNext()) { | |
var folder = folders.next(); | |
var file = files.next(); | |
file.moveTo(folder); | |
var lr = lastrow + 1; | |
// Static data | |
sheet.getRange('g' + lr).setValue(file.getUrl()); | |
} | |
} | |
} | |
function onOpen() { | |
var ui = SpreadsheetApp.getUi(); | |
ui.createMenu("Auto Trigger") | |
.addItem("Run","createNotesDoc") | |
.addToUi(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment