google-apps-script

Script to run on specific sheet

旧巷老猫 提交于 2020-04-14 08:56:13
问题 I have a script that I have been using, but it only works with, as written, the active sheet (pulls a list of documents from the specified directory in Google Drive). How can transform this to run on a specific sheet. The name of the sheet is "Per 7". function list_all_files_inside_one_folder_without_subfolders(){ var sh = SpreadsheetApp.getActiveSheet(); var folder = DriveApp.getFolderById('0B4zzmqQYDRm2flZPRFVWd1FfSGpJTXFmcWlSLXVVTUZJRjNlU3QzTER6aHFsYVEzTDdrS00'); // I change the folder ID

getdata() Script time out only when time-triggered

心已入冬 提交于 2020-04-14 06:43:12
问题 I'm importing a range from another spreadsheet and pasting it in the current spreadsheet with this script: function getdata() { var values = SpreadsheetApp.openById('XXXXXX'). getSheetByName('SheetB').getRange('A4:AZ484').getValues(); var destsheet = SpreadsheetApp.getActive().getSheetByName('Sheet1'); var destrange = destsheet.getRange('B520:BA1000'); destrange.setValues(values); } When firing the script manually the execution lasts around 20 seconds and has no problems at all: [19-09-06 23

Google Classroom Apps Script - CourseWork.list permission error

匆匆过客 提交于 2020-04-13 08:06:39
问题 I am trying to access course work from my Google Classroom in a Google Apps Script using the Classroom API v1. I followed the steps in the Quickstart to successfully retrieve my course list, but when I tried to access the coursework in one of my classes using the following: var coursework = Classroom.Courses.CourseWork.list('valid courseId'); I get a 'The caller does not have permission' error. I can successfully retrieve the coursework list using the APIs Explorer, though. From playing with

Null value returned to Apps Script webapp for a certain spreadsheet by server function

筅森魡賤 提交于 2020-04-13 06:11:29
问题 I am trying to return the data in the spreadsheet to an Apps Script published as a webApp. However, for one of my spreadsheets (link), the returned data is null . I logged the the data before returning to make sure that it isn't null, and I can see them in the logs. This is my code: function doGet(){ return HtmlService.createHtmlOutputFromFile('index'); } function spreadsheetTest() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheetByName("Sheet1"); var maxRows = sheet

Null value returned to Apps Script webapp for a certain spreadsheet by server function

匆匆过客 提交于 2020-04-13 06:11:07
问题 I am trying to return the data in the spreadsheet to an Apps Script published as a webApp. However, for one of my spreadsheets (link), the returned data is null . I logged the the data before returning to make sure that it isn't null, and I can see them in the logs. This is my code: function doGet(){ return HtmlService.createHtmlOutputFromFile('index'); } function spreadsheetTest() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheetByName("Sheet1"); var maxRows = sheet

Using Google Sheets scripts, why does my if statement always return false when comparing cell values?

瘦欲@ 提交于 2020-04-11 05:44:27
问题 I need to compare two cell values and act on them if they are different. My "if" statement always returns false when comparing the cell contents however, and I can't figure out why: function onEdit() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheetByName('Sheet1'); // apply to sheet name only var testvalues = sheet.getRange('A1:A2').getValues(); // array of values to be tested var testvalue1 = testvalues[0]; // The contents from A1 var testvalue2 = testvalues[1]; //

Script runs twice on google form submit trigger

泄露秘密 提交于 2020-04-10 18:52:26
问题 I'm create Google form and google app script with sendFormByEmail function, also I set on form submit trigger for this function, my issue is this script run two time on form submit and I'm getting two email, I want only single email on form submit. my script code is below. var no_repeat=0; function sendFormByEmail(e){ var email = "test@XXXXDXtest.com"; var s = SpreadsheetApp.getActiveSheet(); var headers = s.getRange(1,1,1,s.getLastColumn()).getValues()[0]; var message = ""; var subject =

How to forward email to another address with sendEmail(to,replyTo, subject, body)

生来就可爱ヽ(ⅴ<●) 提交于 2020-04-10 06:09:47
问题 I appreciate if you could help. I need to find all unread emails in my gmail 1@example.com and send them all to 2@example.com by using sendEmail(to,replyTo, subject, body) https://developers.google.com/apps-script/reference/mail/mail-app I tried to write a script but unfortinately it does not want work. I hope you could help function RespondEmail(e) { //send response email var threads = GmailApp.search("to:(1@example.com) label:unread"); for (var i = 0; i < threads.length; i++) { threads[i]

Getting title of slide in Google Apps Script

核能气质少年 提交于 2020-04-10 04:46:37
问题 I'm attempting to write a google apps script that takes the slide titles of every slide (as they are in the master slides) and put them in a nicely formatted table of contents on slide 2. It doesn't necessarily have to be done with apps script, but this is the best way I could think of. function readPageElementIds(presentationId, pageId) { var response = Slides.Presentations.get( presentationId); Logger.log(response.slides) for (var i = 0; i < response.slides.length; i++) { var slide =

How to upload files to firebase storage from google drive using Apps Script?

ぐ巨炮叔叔 提交于 2020-04-08 13:10:42
问题 I need some users to be able to upload files to firebase storage, but they're non tech-savvy, so I will let them upload to drive first, and mirror drive from storage. The thing is, I can't figure out how without having to host a server; google apps scripts can't access firebase storage easily (it can access both firebase databases though) and I need a server to use the google drive API, which could be done using firebase cloud functions, but I wonder if there is an easier alternative. 回答1: An