w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Google Apps Script Regex exec() returning null
Although this question was already answered on the comments, I'll make a proper answer. One important issue to understand this problem is on the exec behavior when the regex have the g flag. Which, when called sequentially will try to look for the "next" match, even if you pass on a different string. Here is the documentation link on MDN. And although MDN states that you should take care not to re-create the RegExp object (even a literal), because it might reset the lastIndex property. At least in Apps Script that's not true. If a regex literal is used in the exact same spot in the code over and over, Apps Script caches the regex and re-uses the same object. This two effects combined meant you were triggering this "next match" behavior on your code unknowingly. The easiest solution fo

Categories : Javascript

Through Google Apps Script get all user information on a spreadsheet of a google apps domain
Some of what you are looking for is best requested via the Admin SDK. You may want to also check out other Google Data APIs in more detail, you could put together some good reporting tools. Many of the APIs can be used in Google Apps Script by using the UrlFetch service. There's an OAuth flow built in that service that is quite nice for OAuth 1 flows, and it's not too bad to create a decent Google OAuth 2 flow with UrlFetch as well. Then you can make authenticated requests to those APIs and handle the responses accordingly with Apps Script.

Categories : Google Apps Script

Google Apps Script Spreadsheets - Assign script to image from a script
This would be a cool feature, but here is a possible workaround, it might even offer more functionality. You can build a UI using Google API. More detailes here. The UI allows you to create side bars/menus/etc. You could even create floating dialog windows. Using AbsolutePanel, you can even choose where the dialogue shows up.

Categories : Google Apps Script

Run a line of script via a variable based on a value inside the worksheet - google apps script
One option may be to use eval(), but remember you have to be careful with this function. ... var doThat = ss.getRange("A1").getValue(); eval(doThat); ...

Categories : Google Apps Script

How to separate script editor from document (google apps script)
Yes, when you create a new document in Drive you can select Script. If you don't see the script option, try going here. You will, however, need to call your document using getByID. There my be other complexities if you are using onEdit type triggers. A lot more information can be found under the Types of Scripts heading at Google Apps Scripts Documentation. You could go advanced and pull your script in behind the Document as a Library and then using the script behind the Doc to make the calls to the library, but that's a bigger discussion.

Categories : Google Apps Script

Google apps script :: Is it possible to get the cursor position or get the selected text from Google Document
Currently there is no such API. However, there is an open issue on the Issue Tracker. You can star this issue to register your interest and be notified to update to it

Categories : Javascript

Is it possible to Use Google Apps Script to check condition in Google Drive Forms?
Google Forms does not support client-side validation like that, at this time. Deploying an Apps Script as a web app would allow you to do it, but you have to create all of the formatting and functionality yourself. The recent inclusion of data validation functions in Apps Script in conjunction with Google Forms supporting some scripting access means that we could see something along these lines in the future. Would certainly go a long way toward making Google Forms more useful.

Categories : Google Apps Script

Upload text file to Google Drive with Google Apps Script
To do a file upload, you cannot use a server handler. You must use a FormPanel and a Submit button. See the FileUpload widget's documentation.

Categories : Javascript

Need help finding the maximum value in a column in Google Sheets using Google Apps Script
You can use the method setFormula(formula) and use a formula like =MAX(Range). The method getDataRange() might be useful. After you get the range of data you can determine the maximum number of rows getLastRow() and columns getLastColumn().

Categories : Google Apps Script

How to edit the document after uploading it on google drive using Google Apps Script
Currently, when you upload a document/spreadsheet using Apps Script, it is uploaded in the same format i.e. it is not converted to Google Docs format. There is an open issue asking for this feature. You can star the issue to register your interest.

Categories : Google Apps Script

how to read, with google apps script, the heading reference in a google docs
Is it possible to read the heading reference at all? Absolutely, at least from the Table of Contents. Those references are in the attributes of the TOC entries. You can see an example, with a script, in this answer.

Categories : Google Apps Script

Text formatting for strings in Google Documents from Google Apps Script
Use the functions describe at the API site here You can manipulate the text setting all styles as much as you want. For example: var file = DocsList.getFileById('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); file.replaceText('Old text string',newTextString); var newTextString = 'foo bar'; var doc = DocumentApp.openById('DOCUMENT_ID_GOES_HERE'); var text = doc.editAsText(); text.setItalic(startOffset, endOffsetInclusive, italic)

Categories : Javascript

How can I get URL parameters passed to a Google Spreadsheet using Google Apps Script?
This is not possible today. As you noted, doGet, doPost are the ones that can grab the variables when deployed as a web app. Please log an enhancement on the issue tracker

Categories : Google Apps Script

Can the google spreadsheet 'query' function be used in google apps script?
No, there is no API for the Query function that allows it to be called from Google Apps Script. (There is no way to call ANY spreadsheet function in this way, in fact.) You can get some similar functionality without writing it all yourself, though. The 2D Arrays Library includes a variety of "filter" functions that let you retrieve matching rows.

Categories : Google Apps Script

Modify Google Spreadsheet via Google Apps Script Values Only
function archivedata(){ //creates my archive spreadsheet var ss1 = SpreadsheetApp.getActiveSpreadsheet(); var data = ss1.getSheetByName("Sheet1").getDataRange().getValues(); var ss2 = SpreadsheetApp.create("New spreadsheet"); ss2.getActiveSheet().getRange(1,1,data.length,data[0].length).setValues(data); ss2.renameActiveSheet("newsheet"); }

Categories : Google Apps Script

getting Current script version using Google Apps script
If you mean "Can we programmatically retrieve the script version number?", the answer is no. There is an outstanding request for this, in Issue 1369, so visit the issue tracker and star it to indicate your own interest. Perhaps you mean "Can we programmatically retrieve the most recent source code?" You can Import and Export Stand-alone script files through the Drive SDK. In Apps Script, this can be accomplished using UrlFetch Services. There is no way at this time to retrieve the source of container-bound scripts, except through the Script Editor. (See Limitations.)

Categories : Google Apps Script

Google Apps Script run when SpreadSheet is change by another Script
The onChange() function will not have reference to the UI. For example, if there are multiple people who have the same UI open, which one should be updated ? So, the solution to your problem is for your UI code to poll the spreadsheet regularly and update the UI if the spreadsheet has changed. To do so, you can use the undocumented addTimer() method. See this SO question & answer for a nice example

Categories : Google Apps Script

How could I get the Google Site's div width with Google Apps Script?
I don't think it is possible. That is because your Apps Script resides within the Google Site and it cannot access any of the DOM outside the Apps Script's UI. You can open an issue in the Issue Tracker

Categories : Google Apps Script

Google Apps Script API rackspace DNS
I found the solution: var Url="https://dns.api.rackspacecloud.com/v1.0/829221/domains/" ; var response1 = UrlFetchApp.fetch(Url, { "headers": { 'X-Auth-Token': Token }})

Categories : Api

RequireJS with Google Apps Script
I found the answer while reading JavaScript Module Pattern: In-Depth The code inside the module didn't have access to Logger. Passing this as a parameter makes it work. define( function(g) { g.Logger.log("Monkey"); }(this));

Categories : Google Apps Script

Google Apps Script url "routes"
The doGet() function has access to GET parameters, but not the URL itself, so you can't really do what you're thinking of with Apps Script. What you could do is use Google Apps Script as a backend to a web app running something like AngularJS, which has client-side routing. You have to host the app elsewhere (the Caja sanitiser doesn't support serving AngularJS yet), and you have to use JSONP as your exchange format, as you can't use Apps Script apps for AJAX endpoints. Here is an example from Keisuke Ohashi: Front end (note: hosted on Google Drive) Content service code ScriptDB code

Categories : Google Apps Script

Google Apps Script in Form
If you are building a form that you will be emailing to the students, then when you set up the form you can have it log all their email addresses for you without you having to write any script at all. Here is a great way to get started writing a new form... go to this page: http://www.google.com/drive/apps.html?usp=ad_search and scroll down to the "Forms" section then click on "Create". This should walk you through everything you will need to set up the form, and the results will be put into a spreadsheet for you, along with the students' email addresses. You can keep the resulting spreadsheet private so that you will be the only one who can view all the responses. I hope that helps.

Categories : Google Apps Script

Browser Pop up in Google Apps Script
A jQuery dialog will suit your needs. It is an overlay to the current window - not a "pop up". The demo code here can be easily adapted to Google Apps Script. Here it is, with much of the extra bits removed: Code.js function doGet() { var template = HtmlService .createTemplateFromFile('ModalForm'); var htmlOutput = template.evaluate() .setSandboxMode(HtmlService.SandboxMode.NATIVE) .setTitle('jQuery UI Dialog - Modal form'); return htmlOutput; } ModalForm.html <!-- Adapted from http://jqueryui.com/dialog/#modal-form --> <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script src="h

Categories : Javascript

Google Apps Script CoffeeScript
You can't, because it's a JavaScript execution environment, not a CoffeeScript execution environment. Google would have to add support for this themselves. You could write locally in CoffeeScript and put the output code into the Google Apps Script editor?

Categories : Google Apps Script

Is it possible to scale Google Apps Script?
Your GAS script scales up automatically. The only thing that you should be worried about is your code where, if you have locks, thousands of users waiting for a lock will cause delays to the user. Other than that, scaling up shouldn't be a problem. After all, there are possibly millions of scripts being run by different users.

Categories : Google Apps Script

Google Site Apps Script
How does the script run and who had access to it. There are 3 (or4) access levels for any web app - only you, anyone in the domain, anyone, anyone including anonymous. Have you set the appropriate access permission for your app.

Categories : Google Apps Script

doPost Twice in Google Apps Script?
I think you are just adding the wrong UI element to the app in your doPost. Instead of app.add(app.getElementById('formContent')); use app.add(app.getElementById('mainForm'));

Categories : Google Apps Script

Google Apps Script Web App on my Domain
This isn't currently supported. See (duplicate) Embedding Google Apps Script WebApp in WordPress Page. Visit Issue 852 and star it for updates. (There are also some potential work-arounds described in the issue comments.)

Categories : Google Apps Script

lost google apps script project
if you truncate your app url before "exec" and replace with "edit" you get this url : https://script.google.com/macros/s/AKfycbyyPyHTQEiklppiU3xyJxvuCZZLLBdY-C64We4W_YlL2amWincl/edit that should work ;-) Edit : you could also simply use the drive's search tool since it searches for any string inside your documents : search for 'Hello world' and it will find all occurrences of this string, including your script...

Categories : Google Apps Script

Has the Url Shortener in Google Apps Script changed?
Yes. It has. I figured it out the hard way. Just make a small change for it to work function getShortenedUrl(url){ var longUrl = UrlShortener.newUrl(); longUrl.setLongUrl(url); var shortUrl = UrlShortener.Url.insert(longUrl); return shortUrl.getId(); }

Categories : Google Apps Script

setCollectEmail is not supported in Google Apps Script
I believe you can only collect the email if you are running Google Apps for Business/ Education/Domain. See here: https://developers.google.com/apps-script/reference/forms/form#collectsEmail() Cheers.

Categories : Google Apps Script

How to extend Google apps script classes
You cannot extend prototypes of Google's Classes. You can find comments about this on the issue tracker, Issue 708

Categories : Javascript

Google Apps Script - Get All Links in a Document
You are right ... search and replace is not applicable here. Use setLinkUrl() https://developers.google.com/apps-script/reference/document/container-element#setLinkUrl(String) Basically you have to iterate through the elements recursively (elements can contain elements) and for each use getLinkUrl() to get the oldText if not null , setLinkUrl(newText) .... leaves displayed text unchanged

Categories : Google Apps Script

Overwrite Spreadsheet in Google Apps Script
You are probably looking for Sheet.clear(). There are few options for deleting contents and formatting here.

Categories : Google Apps Script

Google apps Script Resource tool
are you thinking of something like this ? The code is very simple, just add items to list 2 in a handler function triggered by list1 Data are defined in a 2D array. Here is the full code of this small demo app. var subItems = [['subCategory 1 of 1','subCategory 2 of 1','subCategory 3 of 1','subCategory 4 of 1'],['subCategory 1 of 2','subCategory 2 of 2','subCategory 3 of 2','subCategory 4 of 2'], ['subCategory 1 of 3','subCategory 2 of 3','subCategory 3 of 3']]; function doGet() { var app = UiApp.createApplication().setTitle('test listBox'); var panel = app.createHorizontalPanel().setStyleAttribute('padding','40px'); var sHdlr = app.createServerHandler('updatelist').addCallbackElement(panel); var items = ['category 1','category 2','category 3']; va

Categories : Google Apps Script

Accessing sent email in Google Apps Script
For the issue of search Gmail, have available the following Gmail search operators, operators after: before: can help you. To get the ID of the email sent, I do not know how to get it easily. A proof of concept that comes to mind and that you can adapt and test, is something like: ... GmailApp.sendEmail("name@gmail.com","Subject","Body",{replyTo: "myname+modifier@gmail.com"}); do { /* The search should be as accurate as you can */ threads = GmailApp.search('replyTo:name+modifier@gmail.com is:sent before:2013/08/27 after:2013/08/27 subject:"Subject"', 0, 1); } while(!threads.length); ... Besides making all necessary validations (e.g. set a timeout to avoid an infinite loop), will have to check that this does not give problems, e.g. Script invoked too many times

Categories : Email

PDF prevention to download on Google Apps Script
I have investigated this in the past and it was not possible, I looked again today at both the Drive and DocList API through google script and its not possible still. A cursory look at the DRIVE SDK does not indicate that is possible either. What is the use case you are looking for? Many a time you can wrap the doc in a iframe on a Google site to prevent downloading.

Categories : Pdf

google apps script conditional if statement
You havent been really clear but i hope i got what you meant. I solve it by using two built in js stuff. we cut the string to the first latter. we matching the cutted part to regular expression. Consider view that on JSFIDDLE lets write the markup first: <form> <input name="last" type="text"/></form> <br><br> <div id="status"> </div> now some JS: var rel = new RegExp("[a-l A-L]"); var rez = new RegExp("[m-z M-Z]"); $("form input").on("change",function(e){ vall = $("form input").val().substr(0,1); console.log(vall); if (rel.exec(vall)) { $("#status").text("We Got a winner! the last name starts with letter from a-l"); } else if (rez.exec(vall)) { $("#status").text("Hodey! the last name starts with letter

Categories : Javascript

UrlFetch put method using Google Apps Script
Credentials are needed to test this, so that's up to you. You probably need to both stringify & encode the payload. You also had incorrect capitalization on contentType, which you could check with UrlFetchApp.getRequest(). function updateProducts_version2a(){ try{ var url ="https://app.ecwid.com/api/v1/xxxx/product?id=xxxxx&secure_auth_key="+products_authkey; var payload = {price:62755}; var payload_json = encodeURIComponent(JSON.stringify(payload)); var options ={method:"put",contentType:"application/json",payload:payload_json,muteHttpExceptions:true}; var result = UrlFetchApp.fetch(url, options); var response = result.getContentText(); var res_code = result.getResponseCode(); var x = 1; }catch(e){ Browser.msgBox(e); } } This next versi

Categories : Javascript

Google Apps Script Panel Removal
Panels don't show up as parameters, only input fields do. You will have to retrieve the panel you want to remove using it's ID: ... // Create a vertical panel and add the grid to the panel var step1panel = app.createFlowPanel().setId('someUniqueIdString'); ... and ... function proceedtostep2(eventInfo) { var app = UiApp.getActiveApplication(); app.remove(app.getElementById('someUniqueIdString')); return app; } But removing all elements from a application window does not close the window. The Window only remains in a ugly state. Adding other widgets after the remove is OK but you should use some fresh ID's. If you use old ID strings with new widgets bad things happen.

Categories : Google Apps Script



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.