google-apps-script

How to pass variables into an HTML body

这一生的挚爱 提交于 2020-06-28 11:15:01
问题 I have created this script that allows me to select a certain food item and the serving size and then it calculates nutritional value, adds it to a database, sums it all at the end of the day and sends me an email with an overview. It almost all works, I am just having trouble passing some variables from my script into the HTML formatted email. In the portion of the code below, totals is the data values from a spreadsheet range. I expect the retrieved values of calories , caloriesFromFat ,

How can I reference a Google Apps Script .html file from another library?

自闭症网瘾萝莉.ら 提交于 2020-06-28 11:03:20
问题 I'm writing a set of HTML pages that will be served on the Google Sheets sidebars and will connect to our internal database. Each page is set up on its own .html file within a single Google Apps Script project. I'd like to pull these files out to a single project and reference this as a library like I can do with my other .gs script files. Specifically, how can I write the "MyLib.page" line below? Library project: Code.gs function myFunc() { Logger.log("Hallo Werld!");} page.html <h1> Hello

Dynamic dependent dropdowns on Google Form

一个人想着一个人 提交于 2020-06-28 09:05:33
问题 I need to add the following functionality on a google form - I need to have two dropdowns on the form- Dropdown1 values are being populated from the google sheet using a script. Dropdown2 values must also be populated from the google sheet BUT must change based on the value selected in Dropdown1 on the form. Since Dropdown1 has many values in the list, using the "go to section based on answer" is not an option to show Dropdown2. How can I implement this cascading/dependent dropdown

Dynamic dependent dropdowns on Google Form

江枫思渺然 提交于 2020-06-28 09:05:01
问题 I need to add the following functionality on a google form - I need to have two dropdowns on the form- Dropdown1 values are being populated from the google sheet using a script. Dropdown2 values must also be populated from the google sheet BUT must change based on the value selected in Dropdown1 on the form. Since Dropdown1 has many values in the list, using the "go to section based on answer" is not an option to show Dropdown2. How can I implement this cascading/dependent dropdown

Is it possible to invoke SpreadsheetApp.getUi() via onFormSubmit in google app script?

耗尽温柔 提交于 2020-06-28 07:22:13
问题 With my spreadsheet bound script, this code works fine when invoked from onOpen . When invoked from onFormSubmit I get this error: "Cannot call SpreadsheetApp.getUi() from this context." function showSidebar(issue,row) { var html = HtmlService .createTemplateFromFile('MySidebar'); html.issue = issue; html.row = row; SpreadsheetApp.getUi() .showSidebar(html.evaluate().setTitle('Alert')); } 回答1: It's not going to work because, technically, the spreadsheet isn't the "current instance" of the

How to make a custom validation function like requireTextMatchesPattern(pattern) function using Google apps script?

时光怂恿深爱的人放手 提交于 2020-06-28 06:15:13
问题 Final Objective The final objective is to have the ability to define custom validator for Google Forms item like requireTextMatchesPattern(pattern). Use Case This custom validator will be used for example to compare what the user enters in the form item field with more than one value. or at least to have a custom functionality to execute when the user enters not valid data in the field. Example I have 3 participants, I want to make a simple authentication mechanism to make sure that the

Is it possible to export questions and multiple choice options from a Google Form to a Google Sheet?

只愿长相守 提交于 2020-06-28 05:43:08
问题 We have a series of Google Forms that contain multiple choice questions, each with 4 possible answers. I would like to be able to export the question and all possible answers to a Google Sheet for all of the questions and answers in that Google Form. For example: Q1: What is the capital of England? A: London B: Paris C: Madrid D: Helsinki I've tried a variety of add-ons. There are loads that allow Google Sheets > Google Form, but nothing in reverse (that I can find), so I assume it will be a

Storing the first row as object[name], getting coresponding row/column value

最后都变了- 提交于 2020-06-28 05:26:07
问题 I'm looking for a way loop through a Google sheet to store the first row as an object key and place the corresponding value of the row/column in the object[key] = value. This is what I'm hoping to export //row 1 values [{objName1:value1_1}, {objName2:value1_2}, {objName3:value1_3}, {objName4:value1_4}, {objName5:value1_5}, {objName6:value1_6}, {objName7:value1_7}, {objName8:value1_8}] //row 2 values [{objName1:value2_1}, {objName2:value2_2}, {objName3:value2_3}, {objName4:value2_4}, {objName5

Call Library function from html with google.script.run

亡梦爱人 提交于 2020-06-28 05:11:30
问题 I implement library with Google App Script and I have some difficulties to call a function from library using google.script.run. Here is the code of my Library : Code.gs function ShowSideBar() { var html = HtmlService.createTemplateFromFile('Index_librairie').evaluate() .setTitle('Console de gestion') .setWidth(300); SpreadsheetApp.getUi() // Or DocumentApp or FormApp. .showSidebar(html); } function execution_appeler_par_html(){ Logger.log("execution_appeler_par_html"); } Index_librairie.html

How to format UnprotectedRanges?

夙愿已清 提交于 2020-06-28 05:11:19
问题 I would like to put a red border around each cell in a spreadsheet which does not have any protection assigned to the cell or range of cells. I know how to set a border but how do I access the formatting for the unprotectedranges? function wtf() { var ui = SpreadsheetApp.getUi(); var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; var protection = sheet.protect(); var unprotected = protection.getUnprotectedRanges(); for (var i = 0; i < unprotected.length; i++) { ui