custom-function

How to get the file URL from file name in Google Sheets with correct Authorization via custom function/script

允我心安 提交于 2019-11-29 18:44:34
I would like to create a custom function that pulls a Drive URL from a file name in Google Sheets. So, using the code below: If I have a valid file name in cell A1 The function =getFile(A1) would return the URL When I run my script from within the script editor, the return value works. When I run the function getFile() from within my sheet, I get the error below. My code: function getFile(cell) { var filename = encodeURI(cell); var url = "https://www.googleapis.com/drive/v3/files?fields=files(id,name)&q=name+contains+'" + filename + "' and trashed=false"; var params = { method: "GET", headers:

Spark Scala - How to group dataframe rows and apply complex function to the groups?

馋奶兔 提交于 2019-11-29 04:06:38
问题 i am trying to solve this super simple problem and i am already sick of it, I hope somebody can help my out with this. I have a dataframe of shape like this: --------------------------- | Category | Product_ID | |------------+------------+ | a | product 1 | | a | product 2 | | a | product 3 | | a | product 1 | | a | product 4 | | b | product 5 | | b | product 6 | --------------------------- How do i group these rows by category and apply complicated function in Scala? Maybe something like

Custom Functions with add-ons?

[亡魂溺海] 提交于 2019-11-29 02:29:25
I've been trying to create a Google Spreadsheet plugin from some existing Google App Scripts that I have, and one important part of this app script is Custom Functions. Though the documentation for the add-ons doesn't indicate that this is supported, the documentation for Custom Functions does indicate that you can. https://developers.google.com/apps-script/guides/sheets/functions Through testing, I have not once been able to get Custom Functions exposed through a add-on. Does anyone know the secret sauce to get this to work? Answer According to Eric Koleda in [Code.gs - date_add_and_subtract]

Debugging a custom function in Google Apps Script

时光总嘲笑我的痴心妄想 提交于 2019-11-28 04:54:54
I am trying to create my first custom function for a Google Spreadsheet in Apps Script and I am having a hard time using the debugger. I am working on the custom function demo code from the Google documentation and I have set a breakpoint in the custom function drivingDistance(origin, destination) that is used in a cell of my spreadsheet. The problem I have is, that that the debugger shows the parameters that are passed into the function as being undefined . The content of any other variables that are created during execution is displayed correctly though (as long as they do not depend on the

Custom Functions with add-ons?

故事扮演 提交于 2019-11-27 16:44:27
问题 I've been trying to create a Google Spreadsheet plugin from some existing Google App Scripts that I have, and one important part of this app script is Custom Functions. Though the documentation for the add-ons doesn't indicate that this is supported, the documentation for Custom Functions does indicate that you can. https://developers.google.com/apps-script/guides/sheets/functions Through testing, I have not once been able to get Custom Functions exposed through a add-on. Does anyone know the

Permissions for custom functions in Spreadsheets

大城市里の小女人 提交于 2019-11-27 16:27:14
I am using a new feature of SpreadSheet in Google Sheets: "Named and protected ranges". In this range of protected cells, I use arithmetic built-in functions and my own written functions. The trigger to run my functions is on edit spreadsheet. Users with write permissions, sharing the link of the spreadsheet, can't properly run my functions for permissions problem while built-in functions run properly. Own can I grant permissions for my functions to run as Google Sheets built-in functions. Henrique G. Abreu Built-in functions (Google Spreadsheet functions) have nothing to do with your

Supply API key to avoid Hit Limit error from Maps Service in Apps Script

风格不统一 提交于 2019-11-27 15:52:18
I have a Google Sheet where we are fetching the driving distance between two Lat/Lng via the Maps Service . The function below works, but the matrix is 4,500 cells, so I'm getting the "Hit Limit" error. How can I supply my paid account's API key here? Custom Function function drivingMeters(origin, destination) { if (origin=='' || destination==''){return ''} var directions = Maps.newDirectionFinder() .setOrigin(origin) .setDestination(destination) .getDirections(); return directions.routes[0].legs[0].distance.value ; } Example use: A1: =drivingMeters($E10,G$9) Where E10 = 42.771328,-91.902281

How to evaluate a spreadsheet formula within a custom function?

孤人 提交于 2019-11-27 15:09:16
In a spreadsheet I can enter =SIN(45)+123 in a cell, and it will be evaluated. How can I evaluate spreadsheet functions within a custom function, something like an "eval" function that would work like this : function myFunc() { return Sheet.eval("=SIN(45)+123") } is it possible ? Note that I don't care about the SIN function in particular, what I want is to have access to the complete arsenal of spreadsheet functions ( PMT , QUERY , NPER , etc..) Spreadsheet functions from Apps-Script Not possible - This has been asked many times. Suggest you check the google-apps-script issue list to see if

Not allowed to execute sendEmail() from custom function, but OK in script editor

巧了我就是萌 提交于 2019-11-27 09:50:19
I have been trying to find a way to send single row of data to a specific email address in a "live/running" spreadsheet that I am using within my domain, to keep track of truck drivers and their pick up numbers. I managed to piece together this little bit of code using the Google Apps Script Editor available in sheets: function sendEmail() { var sheet = SpreadsheetApp.getActiveSheet(); var activeRow = sheet.getActiveCell().getRow(); var cellID = "H" + activeRow; var dataRange = sheet.getRange(activeRow, 1, 1, 6); var EMAIL_SENT = "EMAIL_SENT"; var data = dataRange.getValues(); Logger.log(data

Google apps script error: “You do not have permission to call protect”

安稳与你 提交于 2019-11-27 09:38:41
I'm trying out my first Google Sheets Apps Script. I'm trying to make a custom function (via a bound script) that will check if the cell it's in is protected. If it is protected, it should change the cell's value to (for now at least) the protection type. I can successfully run the simple demo script in the docs: function DOUBLE(input) { return input * 2; } But when calling Range::protect, I can an error "You do not have permission to call protect" Here's the function function isProtected() { var range = SpreadsheetApp.getActiveRange(); var protection = range.protect(); return protection