google-apps-script

How do you change formatting within a google doc for multiple occurrences using findText()?

六眼飞鱼酱① 提交于 2021-02-10 22:26:19
问题 I am trying to find text within a google doc and replace with a subscript notation - replace "a3" with a3 but with the 3 now formatted as a subscript. based on the answer here I wrote some code that is working but only replaces the 1st instance of any occurrence (some are repeated). I wrote the following: for (var k=0; k<subscriptsReplace.length; k++) { subscript = ' a'+subscriptsReplace[k]; find = ' a'+subscriptsReplace[k]+' '; Logger.log(find) var element = body.findText(find); if(element){

How do you change formatting within a google doc for multiple occurrences using findText()?

元气小坏坏 提交于 2021-02-10 22:23:21
问题 I am trying to find text within a google doc and replace with a subscript notation - replace "a3" with a3 but with the 3 now formatted as a subscript. based on the answer here I wrote some code that is working but only replaces the 1st instance of any occurrence (some are repeated). I wrote the following: for (var k=0; k<subscriptsReplace.length; k++) { subscript = ' a'+subscriptsReplace[k]; find = ' a'+subscriptsReplace[k]+' '; Logger.log(find) var element = body.findText(find); if(element){

How to call an Apps Script library function in Google Sheet

∥☆過路亽.° 提交于 2021-02-10 22:15:52
问题 I created a Library in Google script as a standalone script with a function function1 . I published a version of this script. I also have a spreadsheet, and using a bound script, I added my library with identifier XXXX and managed to launch from scripts.google.com the function using a wrapper around function1 and logging the results : function function2() { return XXXX.function1(); } function test() { Logger.log(function2()); } The problem is I cannot call this function from a cell in the

How to call an Apps Script library function in Google Sheet

无人久伴 提交于 2021-02-10 22:13:06
问题 I created a Library in Google script as a standalone script with a function function1 . I published a version of this script. I also have a spreadsheet, and using a bound script, I added my library with identifier XXXX and managed to launch from scripts.google.com the function using a wrapper around function1 and logging the results : function function2() { return XXXX.function1(); } function test() { Logger.log(function2()); } The problem is I cannot call this function from a cell in the

Community Connector Tutorial results in “Unknown data source”

梦想的初衷 提交于 2021-02-10 22:11:29
问题 As a first step toward developing my own Community Connector, I have followed the Codelabs Community Connector Tutorial: https://codelabs.developers.google.com/codelabs/community-connectors/#0 However, at the final step of previewing the output in a report, the connector fails with the error: Unknown data source The data source associated with this component could not be loaded We were not able to find the data source associated with this component. This can happen when a data source is

ReferenceError: google is not defined - Google Apps script error in Mozilla firefox

孤街浪徒 提交于 2021-02-10 21:58:56
问题 I'm creating a Google Site with Google Apps Script "Enum Sandbox Iframe mode". In Google Developer Docs, It says, to call a custom function, we need to use google.script.run Sample: Code.gs function doGet() { return HtmlService.createHtmlOutputFromFile('index') .setSandboxMode(HtmlService.SandboxMode.IFRAME); } function doSomething() { Logger.log('I was called!'); } index.html <script> google.script.run.doSomething(); </script> When I run this using Google Chrome, Its working perfect. But it

Error msg from custom function when trying to open another spreadsheet. “You do not have permission to perform that action.”

南楼画角 提交于 2021-02-10 20:24:17
问题 I have a custom function that I want to use to retrieve the cell value in a sheet from another spreadsheet. The two parameters of the function are row and col and they determine the cell to reference. Whenever I try to use the function, I get the error "You do not have permission to perform that action." , pointing to the line with the openByID method. Here is my custom function: function TEST(row,col) { var formDataSpreadsheet = SpreadsheetApp.openById(FORM_DATA_SPREADSHEET_ID);

Google script is reprocessing emails

安稳与你 提交于 2021-02-10 20:15:48
问题 Background: I get an email every 6 hours that has hourly logs in the body and I want to put each hourly log into the same spreadsheet so I can scan hour to hour quickly over long periods. I also get random "alarm" emails, which I want to add to that spreadsheet. What I've done: When those emails come in, I apply one of two filters in my work gmail account. One for the alarms, and one for the logs. The filters archive and adds one of two labels to the emails. I have a spreadsheet saved in my

Importing CSV from URL that has line breaks within one of the fields

筅森魡賤 提交于 2021-02-10 18:44:42
问题 I created a script that imports a CSV file from a URL into a Google Sheet. I have used Utilities.parseCsv(csv) in the past with no problems. However, this particular CSV file contains a field that has multiple line returns (ALT+Enter). This causes the parsed file to create extra rows when it encounters these fields. I think the best approach is to sanitize the CSV file before parsing, but I do not know how to do this. The problem field is 'Description' (Column G). Current Script: function

MailApp.sendEmail not working with onEdit function (Google Sheets Script Editor)

江枫思渺然 提交于 2021-02-10 18:37:01
问题 I'm trying to create pop-up and email notifications for when certain daily limits are exceeded on edit of the spreadsheet. When the values relating to today's date exceed the limits and I run the script, both the pop-up and email notifications are sent. But when using the onEdit function, i.e editing the column defined in the edit range.. only pop-up notifications are raised and no emails are sent. Does anyone know why the onEdit function would work for SpreadsheetApp.getUi().alert but not