google-apps-script

google apps script: remove and restore protection

不想你离开。 提交于 2021-01-28 18:33:12
问题 I have a spreadsheet that is editable by everyone with a protected sheet with some ranges unprotected. I want cells that can be altered by a script run by any user (from a menu), but not manually. When I run the script not as the owner it gives an error message when I try to temporarily remove the protection. 回答1: There seems to be no easy way to do this, because functions run from the menu is always executed as "user at the keyboard". One workaround is to publish a Web App to always "Execute

Use for loop to map data from one Google Sheet to another one

六眼飞鱼酱① 提交于 2021-01-28 18:30:33
问题 I'm still fairly new with Google Scripts. I have a student roster Google Sheet with demographic information, including ID numbers. I also have a responses Sheet that automatically collects email addresses on Column B (email addresses are created by the ID number plus "@foo.org"). I'm trying to get my script to parse through auto-collected emails, map the ID portion of the email onto column C. Then I'm using for loops to check the extracted ID number against my main roster, and map the

Firebase short URLs not redirecting

半城伤御伤魂 提交于 2021-01-28 18:15:45
问题 I created a Google Sheet that uses a Google Script to generate short URLs via Firebase API. This is the code in the Google Script function URLShortener(longURL) { var body = { "dynamicLinkInfo": { "domainUriPrefix": "https://go.example.com", "link" : longURL }, "suffix": { "option": "SHORT" } }; var key = 'xxxxxxx' var url = "https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=" + key; var options = { 'method': 'POST', "contentType": "application/json", 'payload': JSON.stringify

Google Sheet to Json Data Live Update Without Refresh Website Page

大兔子大兔子 提交于 2021-01-28 18:12:55
问题 this function runs fine. What I am looking for If someone updates data on google sheet without reloading webpage update DOM element help of any language. I'm using the google sheet json file https://spreadsheets.google.com/feeds/list/1XaFRnQfNPRP86UPNcdgQuCCH6AeVe5FZOxBHaIPZDpM/od6/public/values?alt=json var myData = []; // an example function that will get the data by index so it can be used however you want function showDetails(index) { var selectedData = myData[index]; alert(JSON.stringify

Can't serve HTML on the Google Apps Script callback page in a GMail add-on

☆樱花仙子☆ 提交于 2021-01-28 18:12:05
问题 I am working on a GMail add-on that connects to a third-party service through OAuth2. To obtain the authorization code the following redirect URI is used: https://script.google.com/macros/d/[SCRIPT_ID]/usercallback . Here's a snippet that triggers authorization: var stateToken = ScriptApp.newStateToken() .withMethod( "authCallback" ) .withTimeout( 120 ) .createToken(); var authUrl = _authBaseUrl + "&client_id=" + encodeURIComponent( _clientId ) + "&redirect_uri=" + encodeURIComponent(

Can't serve HTML on the Google Apps Script callback page in a GMail add-on

混江龙づ霸主 提交于 2021-01-28 18:03:28
问题 I am working on a GMail add-on that connects to a third-party service through OAuth2. To obtain the authorization code the following redirect URI is used: https://script.google.com/macros/d/[SCRIPT_ID]/usercallback . Here's a snippet that triggers authorization: var stateToken = ScriptApp.newStateToken() .withMethod( "authCallback" ) .withTimeout( 120 ) .createToken(); var authUrl = _authBaseUrl + "&client_id=" + encodeURIComponent( _clientId ) + "&redirect_uri=" + encodeURIComponent(

Update Google Sheet “Filter View” w/ New Range

早过忘川 提交于 2021-01-28 16:51:36
问题 I have a spreadsheet with various filter views set in place. Normally this works great but occasionally new rows are added and I have to manually update the range in each filter view. I've tried searching for solutions online and came up with the following code that might update the range: function UpdateFilterView() { var dataSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data'); //for each (var dataSheet in sheets){ var lastRow = dataSheet.getLastRow(); var lastColumn =

Update Google Sheet “Filter View” w/ New Range

狂风中的少年 提交于 2021-01-28 16:50:10
问题 I have a spreadsheet with various filter views set in place. Normally this works great but occasionally new rows are added and I have to manually update the range in each filter view. I've tried searching for solutions online and came up with the following code that might update the range: function UpdateFilterView() { var dataSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data'); //for each (var dataSheet in sheets){ var lastRow = dataSheet.getLastRow(); var lastColumn =

Update Google Sheet “Filter View” w/ New Range

故事扮演 提交于 2021-01-28 16:48:55
问题 I have a spreadsheet with various filter views set in place. Normally this works great but occasionally new rows are added and I have to manually update the range in each filter view. I've tried searching for solutions online and came up with the following code that might update the range: function UpdateFilterView() { var dataSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data'); //for each (var dataSheet in sheets){ var lastRow = dataSheet.getLastRow(); var lastColumn =

Update Google Sheet “Filter View” w/ New Range

此生再无相见时 提交于 2021-01-28 16:47:21
问题 I have a spreadsheet with various filter views set in place. Normally this works great but occasionally new rows are added and I have to manually update the range in each filter view. I've tried searching for solutions online and came up with the following code that might update the range: function UpdateFilterView() { var dataSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data'); //for each (var dataSheet in sheets){ var lastRow = dataSheet.getLastRow(); var lastColumn =