google-apps-script

500 error on UrlFetchApp

怎甘沉沦 提交于 2021-02-10 15:15:26
问题 I am trying to pass data of a product list from Magento API to Google Spreadsheet. No authentication was required for the Magento API as I was retrieving the data as a Guest. The API is working perfectly with RestClient. However, 500 error occurred when fetching the REST resource from Googe Apps Script. Exception: Request failed for http://mymagentohost/api/rest/products?limit=2 returned code 500. Truncated server response: Service temporary unavailable (use muteHttpExceptions option to

Google Script: how to send Tablechart in e-mail?

会有一股神秘感。 提交于 2021-02-10 15:00:29
问题 I'm creating a tablechart in Google Script and I want to send this through e-mail. This is my code var data = Charts.newDataTable() .addColumn(Charts.ColumnType.STRING, 'Month') .addColumn(Charts.ColumnType.NUMBER, 'In Store') .addColumn(Charts.ColumnType.NUMBER, 'Online') .addRow(['January', 10, 1]) .addRow(['February', 12, 1]) .addRow(['March', 20, 2]) .addRow(['April', 25, 3]) .addRow(['May', 30, 4]) .build(); var chart = Charts.newTableChart() .setDataTable(data) .enableSorting(true)

Session.getActiveUser.getEmail() blank? Google sheets

旧城冷巷雨未停 提交于 2021-02-10 14:23:22
问题 I want to check the user who is clicking that specific button. When I click on while signed in as my account it runs fine. but if anyone else runs it, it is blank. How can I get the logged user email id? This is my code: function check_User(){ var ui = SpreadsheetApp.getUi(); var usr = Session.getActiveUser().getEmail(); ss.toast(usr); if( usr == "abc@gmail.com" || usr =="myemail@gmail.com"){ return true; } else{ ui.alert("Not authorized"); return false; } } 回答1: See getActiveUser() method

Replace a text keyword with a “Page Break” element in Apps Script

蓝咒 提交于 2021-02-10 13:40:06
问题 I want to replace a specific text keyword with a page break. Here's what I've tried: body.findText("%PAGE_BREAK%").getElement().appendPageBreak() and body.replaceText("%PAGE_BREAK%", "").asBody().appendPageBreak() I'm trying to edit existing documents which have %page_break% somewhere and replace it with an actual page break element. 回答1: The following will suffice under the assumption that "%page_break%" appears either at the end of a paragraph, or in a paragraph of its own. The script

Chicken and Egg situation with retrieve 8-digit codes from new created accounts

走远了吗. 提交于 2021-02-10 12:16:11
问题 I am refactoring a script that creates new user accounts on google script G-Suite API. The script works fine, and prepared an email templates, with login credentials--all as expected. I am not trying to retrieve 8-digit authentication code, and attach it to the email template, since we moved to required 2FA organisation wide. The crux of the problem is, I can't naturally get the codes if the account has not been created. There seems to be some issue -- some type of delay, where I can't get

Chicken and Egg situation with retrieve 8-digit codes from new created accounts

一世执手 提交于 2021-02-10 12:15:47
问题 I am refactoring a script that creates new user accounts on google script G-Suite API. The script works fine, and prepared an email templates, with login credentials--all as expected. I am not trying to retrieve 8-digit authentication code, and attach it to the email template, since we moved to required 2FA organisation wide. The crux of the problem is, I can't naturally get the codes if the account has not been created. There seems to be some issue -- some type of delay, where I can't get

Copy only filtered range to other sheet

送分小仙女□ 提交于 2021-02-10 09:58:49
问题 Hello Everybody I tried to make scripts for copying filtered data but I did not make it. I want to copy filtered data to another sheet automatically function RejectSave() { var ss = SpreadsheetApp.getActive(); var DataSheet = ss.getSheetByName('Import') ss.setActiveSheet(DataSheet, true); var sheet = ss.getActiveSheet(); sheet.getRange(1, 1, sheet.getMaxRows(), sheet.getMaxColumns()).activate(); sheet.getRange(1, 1, sheet.getMaxRows(), sheet.getMaxColumns()).createFilter(); var criteria =

Copy only filtered range to other sheet

孤街浪徒 提交于 2021-02-10 09:58:29
问题 Hello Everybody I tried to make scripts for copying filtered data but I did not make it. I want to copy filtered data to another sheet automatically function RejectSave() { var ss = SpreadsheetApp.getActive(); var DataSheet = ss.getSheetByName('Import') ss.setActiveSheet(DataSheet, true); var sheet = ss.getActiveSheet(); sheet.getRange(1, 1, sheet.getMaxRows(), sheet.getMaxColumns()).activate(); sheet.getRange(1, 1, sheet.getMaxRows(), sheet.getMaxColumns()).createFilter(); var criteria =

Can I use Google Apps Script to make a Google Form display randomized text from a Google Sheet?

冷暖自知 提交于 2021-02-10 08:34:29
问题 Say I have a list of 1000 animals in a Google Sheet (e.g., dog, cat, cow, ..., giraffe). I'll like the Google Form to randomly pick one of these animals every time a respondent opens the Form. E.g., Have you ever seen a __________ ? Here, the blank would be different for every respondent (unless they were lucky enough to randomly get matching animals). I currently have the code to randomly select an animal from the Google Sheet, but I can't figure out how to randomly select an animal for each

Google App Script: Javascript runtime exited unexpectedly

▼魔方 西西 提交于 2021-02-10 06:14:43
问题 I have written an app script that will interact with the bigQuery API and fetch the bigQuery results. API is been hit around close to 60-70 times. In this process sometimes I'm getting the following error message: "JavaScript runtime exited unexpectedly" could someone help me here? Let me know if you need any additional information function fetchTables() { var timezone = "GMT+" + new Date().getTimezoneOffset()/60; var date = Utilities.formatDate(new Date(), timezone, "yyyy-MM-dd HH:mm");