google-apps-script

Google Form: How to save multiple file upload in a specific folder?

夙愿已清 提交于 2020-08-03 05:48:05
问题 I have created a custom form on Google Form which contains an Upload File Question (allowing multiple files). I'm trying to run a script when submitting the form that creates a folder into a specific destination in Drive and that it saves the files uploaded in this one. But I have no idea how to retrieve the ID of the files uploaded and move them into the new folder. Thank you I managed to create the new folder, but I'm not able to select the uploaded file and save them (or move them) to the

Google Apps Script Redeclaration of Const Error

孤者浪人 提交于 2020-08-02 06:34:10
问题 Given this Google Apps Script script: 'use strict' const foo = 2; function bar() { Logger.log(foo + 2); } Running the function bar results in a TypeError: redeclaration of const foo. Why? How is foo being redeclared? 回答1: Seems like it's due to spotty implementation of ES6. I still get the error if I remove foo from the function, so the error is coming from the global const declaration. The below code produces the same error, but no error if you comment out const foo. const foo = 2; function

Google Apps Script Redeclaration of Const Error

廉价感情. 提交于 2020-08-02 06:34:09
问题 Given this Google Apps Script script: 'use strict' const foo = 2; function bar() { Logger.log(foo + 2); } Running the function bar results in a TypeError: redeclaration of const foo. Why? How is foo being redeclared? 回答1: Seems like it's due to spotty implementation of ES6. I still get the error if I remove foo from the function, so the error is coming from the global const declaration. The below code produces the same error, but no error if you comment out const foo. const foo = 2; function

Limit Find and Replace to whole words google sheets .gs function [duplicate]

心不动则不痛 提交于 2020-07-31 05:53:26
问题 This question already has answers here : Javascript: regex for replace words inside text and not part of the words (5 answers) Closed 6 days ago . I have a find and replace function, it replaces every instance of aa in a string, in VBA it would be xlPart Is there a way to set the function so that it replaces only whole words or in VBA language xlWhole Thanks function FindReplaceWSHT(){ replaceInSheet("Elements",'aa','ZZZ'); } function replaceInSheet(shtName, to_replace, replace_with) { var

Get data from Google Sheets without Sheets API

房东的猫 提交于 2020-07-31 05:19:08
问题 I have created an app (React Native) where I am required to show the responses of a google form, so I created the Responses Sheet. Though Sheets API would be the best solution, I do not wish to use it (unless there is no other choice). Is there a way to get the data (csv/json/arrays?/anything else) from the sheet without using Google API? I only want the values from the cells, nothing else. Notes: I want to parse the data in JavaScript. 回答1: I believe your goal as follows. You want to

Add-on menu doesn't get created when published through G-Suite Marketplace SDK, but does through Chrome Web Store

独自空忆成欢 提交于 2020-07-31 05:01:08
问题 Whether by using createAddonMenu() or createMenu(), I can't create menu when add-on is installed through GSM, or when opened with "Integrate With Google" via G-Suite Marketplace SDK. "Test as add-on" via Script Editor works, installation via Chrome Web Store works, and I have no idea what might be wrong. I'm not sure if the script runs in the first place. I've tried existing solutions from StackOverflow such as calling functions in different order, but nothing seems to work. Does someone know

why apps script execution failed only when it is triggered by onEdit event on Google Spreadsheet

寵の児 提交于 2020-07-31 04:33:24
问题 I am working on Google Apps Script. I have apps script that I have wrote that is supposed to be executed by onEdit event on specific sheet. onEdit.gs function onEdit(e) { var syokuninIchiran = new SyokuninIchiran(); syokuninIchiran.syncTable(); } When the above is executed by edit on the sheet, this error occurs: You do not have permission to call openById. Required privilege: https://www.googleapis.com/auth/spreadsheets But, it works with no problem when the script is triggered from Google

Insert image in multiplechoiceitem in Google Forms with Google Apps Script

血红的双手。 提交于 2020-07-31 04:08:06
问题 I need to insert a Google Drive image in each choice of the multiple choice item. Upon checking the documentation, the Class .addMultipleChoiceItem() doesn't support the method .setImage() . Is there another way to insert an image from Google Drive?. Example: var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz'); var item = form.addListItem(); item.setTitle('Do you prefer cats or dogs?') .setChoices([ item.createChoice('Cats'), <------ I need to insert an imagen of a cat in this

Session.getActiveUser().getEmail() returns no Value

六眼飞鱼酱① 提交于 2020-07-30 07:56:48
问题 this is my first Stackoverflow Questions, so I'm trying to do my best to be clear and structured here but please forgive me for beginner mistakes :) So I'm having a little issue with the Script Editor of Google, basically I'm calling the Session.getActiveUser().getEmail() as well as the Session.getEffectiveUser().getEmail() Function yet none of them is returning a value. Here's the full Code I'm using: function onEdit(e){ var email = Session.getActiveUser().getEmail(); var range = e.range;

Copying item .getFeedbackForCorrect between Google quiz forms

主宰稳场 提交于 2020-07-30 07:02:53
问题 The .duplicate() method does not work between forms (well not as far as I can see) so I have written a quick routine to copy multiple-choice items from one form to another. (I'm doing this to set quizzes in Classroom . I have banks of questions on single topics in quizzes for formative assessment and want to combine random questions from these for summative assessment.) The code I've written works fine in copying over the questions but not the feedback. This is my first GAS code so apologies!