google-apps-script

Lock script execution on a document when script is deployed as web app

拥有回忆 提交于 2021-02-08 07:32:07
问题 My Google Apps Script is deployed as web app and can be accessed by any user. Its functionality is to open and change the text in that document. I send the script a document ID as a query parameters like so: https://script.google.com/a/macros/s/AKfycbzCP...TnwHUbXxzDM/exec?docId=1_cMN0nuJadBw6QVjKtdEA6eXhE8ubIoxIJai1ticxnE` Web app opens the document and changes the text in the document. function doGet(e){ var params=e.parameters; var doc = DocumentApp.openById(params['docId']); ... /* change

How to get active user email with installed onEdit trigger?

不羁的心 提交于 2021-02-08 06:48:59
问题 I have a Google spreadsheet with some data. I wrote script to track changes of some specific columns. function onOpen() { var ss = SpreadsheetApp.getActive(); var menuItems = [ {name: 'Turn on', functionName: 'createSpreadsheetEditTrigger'} ]; ss.addMenu('Tracker', menuItems); } function changeTrack(){ const ss = SpreadsheetApp.getActiveSpreadsheet(); const ui = SpreadsheetApp.getUi(); var ws = ss.getActiveSheet(); const headerRow = 4; const editBodyCols = [2, 3, 4, 5]; const fResultCol = 6;

How to get active user email with installed onEdit trigger?

心已入冬 提交于 2021-02-08 06:48:53
问题 I have a Google spreadsheet with some data. I wrote script to track changes of some specific columns. function onOpen() { var ss = SpreadsheetApp.getActive(); var menuItems = [ {name: 'Turn on', functionName: 'createSpreadsheetEditTrigger'} ]; ss.addMenu('Tracker', menuItems); } function changeTrack(){ const ss = SpreadsheetApp.getActiveSpreadsheet(); const ui = SpreadsheetApp.getUi(); var ws = ss.getActiveSheet(); const headerRow = 4; const editBodyCols = [2, 3, 4, 5]; const fResultCol = 6;

File size increases when converting an html file to adobe pdf using google apps script

。_饼干妹妹 提交于 2021-02-08 06:45:48
问题 For some reason, when converting an HTML file to a PDF in Google Apps Script, the file size of the PDF ends up being way bigger than the original HTML file. The code I used to run the test is below: function convertHTMLtoPDF() { // convert a specific message with an attached HTML file to PDF, // and save it to the root directory of Google Drive var threads = GmailApp.search('subject:(Sample HTML)'); var message = threads[0].getMessages()[0]; var attachmentName = message.getAttachments()[0]

Google Apps Script trigger - run whenever a new file is added to a folder

眉间皱痕 提交于 2021-02-08 06:41:17
问题 I want to execute a google apps script whenever a new file is added to a specific folder. Currently I'm using a run-every-x-minutes clock trigger, but I only need to run the script whenever I add a file to a folder. Is there a way to do this? The same as this question - which is now almost 3 years old. The comment below the question states that: There's not a trigger for that, if that's what you're hoping. How are things getting into the folder, and do you have any control over that? – Jesse

Google Apps Script trigger - run whenever a new file is added to a folder

旧街凉风 提交于 2021-02-08 06:39:42
问题 I want to execute a google apps script whenever a new file is added to a specific folder. Currently I'm using a run-every-x-minutes clock trigger, but I only need to run the script whenever I add a file to a folder. Is there a way to do this? The same as this question - which is now almost 3 years old. The comment below the question states that: There's not a trigger for that, if that's what you're hoping. How are things getting into the folder, and do you have any control over that? – Jesse

Google Apps Script trigger - run whenever a new file is added to a folder

点点圈 提交于 2021-02-08 06:39:07
问题 I want to execute a google apps script whenever a new file is added to a specific folder. Currently I'm using a run-every-x-minutes clock trigger, but I only need to run the script whenever I add a file to a folder. Is there a way to do this? The same as this question - which is now almost 3 years old. The comment below the question states that: There's not a trigger for that, if that's what you're hoping. How are things getting into the folder, and do you have any control over that? – Jesse

Random substring error? “TypeError: Cannot find function substring in object…”

ⅰ亾dé卋堺 提交于 2021-02-08 06:24:17
问题 The error is: TypeError: Cannot find function substring in object The code loops through 10 values, checking for the first character being a number. function TypeErrorMystery() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var s = ss.getActiveSheet(); //loop from cell 1-10 for (var i = 0; i < 10; i++) { var range = s.getRange(i + 1, 1) var substring1 = range.getValue().substring(0, 1); //if first character in cell is # if (substring1 === "#" ) { //write over it with "success" range

Parse values from HTML element using Google App Script?

微笑、不失礼 提交于 2021-02-08 06:14:56
问题 I am trying to parse HTML element by class on Google Sites, my code is: function doGet(){ var html = UrlFetchApp.fetch ('http://indicadoresdeldia.cl/').getContentText(); var doc = XmlService.parse(html); var html = doc.getRootElement(); var menu = getElementsByClassName(html, 'span3 utm')[0]; var output = XmlService.getRawFormat().format(menu); return HtmlService.createHtmlOutput(output); } Ween i run the code appear the nexte error message ReferenceError: "getElementsByClassName" is not

Dates (Duration) in Google Sheets Script

女生的网名这么多〃 提交于 2021-02-08 06:14:28
问题 I have a Google Sheet with three columns: - Date and time (timestamp) - Duration - Description I have an script that when I write something in 'Description', inserts in 'Date' the date and time at this moment, and the 'Duration': function onEdit(e) { if(e.source.getActiveSheet().getName() == "Sheet2" ) { var col = e.source.getActiveCell().getColumn(); if(col == 3 ) { // I'm in column three var cellTimeStamp = e.range.offset(0,-2); // First column of the same row var cellTimeDiff = e.range