Posts

Showing posts with the label Google Apps Script

Can A Google Sheets Custom Menu Pass A Variable To Function?

Answer : When you create a menu item with .addItem('Nathaniel MacIver', menuItem2('nm@emailaddress.com')) the function menuItem2 is called with the parameter 'nm@emailaddress.com'. This results in the alert that you see. The return value of the function is undefined (as you don't return anything from it). So you end up with the same menu item as if it was .addItem('Nathaniel MacIver', undefined) which clearly isn't going to do anything. The method addItem takes only a function name, it does not allow for passing parameters to that function. To do what you want, you'll need separate functions for each person, each with an email hardcoded inside that function. Although you can't pass functions that invoke with a variable directly through the .addItem() method, because it only accepts strings, you can take a couple of extra steps (extra steps relative to what you were trying to do) to dynamically create functions that are pre-s...

Conditional Formatting In Google Sheets: Can I Use Custom Function In The 'custom Formula Is:' Field?

Answer : Short answer A custom function can't be used as a part of a custom formula in the Google Sheets' conditional formatting built-in user interface. Explanation In Google Sheets, a custom function is like spreadsheet built-in functions but written by the user using the Google Apps Script editor. They can't modify other objects, only return one or multiple values. By the other hand, a custom function only is calculated when it's added to a cell or when at least one of it's parameters changes. They can't use non-deterministic functions as parameters like NOW(), TODAY(), RAND() and RANDBETWEEN(). Test In order to test the statement in the short answer, I created a did the following: Create a simple custom function function two() { return 2; } Add the custom function as part of a custom formula in the conditional formatting side panel =two()=2 Result: Nothing changed. References Custom Functions in Google Sheets I have also found that custom functions c...

Can You Use Google Apps Script With Python?

Answer : No, Google Apps Script is its own programming language. There are a number of APIs for individual Google Apps, but they are not as comprehensive as what is provided via Google Apps Script. They're generally focused on providing access to the data, and might be suitable if you don't need to edit it. It is now possible to make requests to Google Apps Script from Python via the new Execution API, which uses a REST interface. Related blog post announcement. Learning some JS is still required. Python is amazing, and one of its most amazing qualities is being able to serve as a "glue" of sorts between different modules of a system (regardless of language). My suggestion is to try and make an Adapter/Wrapper around the Javascript commands you will need from Google App Script, exposing pure python functions to the rest of your program so it makes it easier on you. In the end, you will still require to learn some Javascript so... get going.