Stream

Join this community to post or comment

Daniel Frost

Tips & tricks  - 
 
Full write up on how to include images in your Google Apps Script Web Application directly from your google drive, or google apps script project. Hope this helps.
8
2
Faustino Rodriguez's profile photoDaniel Frost's profile photoFilipe Gazzinelli L F Werneck's profile photoGunther Keim's profile photo
3 comments
Add a comment...

Web Apps R&D

Tips & tricks  - 
 
What's the use of SpreadsheetApp.flush()?
Lesson learned the hard way

In order to exchange values between to parallel processes, running in different accounts, we used a shared spreadsheet. But in order for a value to "arrive" it needs to be "flushed".

The sender must e.g.

s.getRange('A1').setValue( 'for receiver'); // changes the value
SpreadsheetApp.flush();

and the receiver must e.g.

SpreadsheetApp.flush();
s.getRange('A1').getValue();

In order to get the change. 

Without SpreadsheetApp.flush() the change of the value will not be reliably determined. 
8
3
Riël Notermans's profile photoIgnacio Baixauli's profile photoAlexander Ivanov's profile photoAlex Vomore's profile photo
4 comments
 
Also counts for DocumentApp.saveAndClose().
Add a comment...

Bruce Mcpherson
moderator

Tips & tricks  - 
 
The other day I posted on how it's possible to run hosted JavaScript unde VBA. Now here's how to serve up your Apps Script directly to Excel and execute it locally on your PC.

Also includes the shims  you'll need to bring the Windows JavaScript engine to the same level as Apps Script

#gde   #googleappsscript   #blogpost   #opensourcesoftware   #vba   #javascript  
4
1
Anees Hameed's profile photoBruce Mcpherson's profile photo
 
Your post are making my life easier.... thanks a ton.
Add a comment...

Bruce Mcpherson
moderator

Tips & tricks  - 
 
 
Today I'm open sourcing my ColorArranger Add-on for Google Sheets. You might find some stuff of interest, especially if you are creating Canvas based Add-ons.

#gde   #googleappsscript   #opensourcesoftware   #blogpost   #html5  
1 comment on original post
8
Add a comment...

Bruce Mcpherson
moderator

Tips & tricks  - 
 
I've open sourced my Sankey Snip Sheets Add-on. You might find some useful stuff there.

#gde   #opensourcecode   #googleappsscript   #html5   #blogpost  
Liberate Excel data from the desktop
14
12
Raul Flores, Jr.'s profile photoRory O Connor (rocits)'s profile photo
Add a comment...

Luis Henrique Souza

Tips & tricks  - 
 
Hi everybody!

I´d like to know how to make this functional as described on actual or new sheets, since nothing happens as showed in the video.
PLEASE HELP!!!

http://googledocs.blogspot.com.br/2015/06/google-sheets-do-more-with-your-data.html
1
Riël Notermans's profile photo
 
Be patient :)
Add a comment...

Riël Notermans

Tips & tricks  - 
 
In the repeated question how and where to store data in GAS, we use this solution to store and grab data for HtmlService applications! 
#ajax #spreadsheets  

We use jQuery Ajax() to fetch data from the Google Visualisation API from a Google Spreadsheet, a command that does not need to open a sheet, read rows, process it etc. You just create a good query, or as you wish, process your data client side which is so much faster.

Besides, it can run parallel tasks, because it uses a callback functoin when the data has 'arrived', just like google.script.run.

A demonstration is shown here


--------------------------
I created a spreadsheet with sample data (make it big, to test speed!):

https://docs.google.com/spreadsheets/d/1dlTRg8KsGq1gDtyWTUpx1vlpPTm0QfeL_oaXdvhWoA4/edit#gid=0

It contains a simple script that reads the spreadsheet data with jQuery AJAX:

https://script.google.com/macros/s/AKfycbyGO3FdFn67MkEUZYBwNVNn45GNtElsgB2KU0ALyZJxAS8kypjl/exec

Example of a query in spreadsheets, try:
"select A,B where D>10"

or 

"select SUM(D) where A = "East"
21
4
Ivan Kutil's profile photoAndrew Hyland's profile photoAlexander Ivanov's profile photoAlexey Isachenko's profile photo
16 comments
 
Yes, but they are unautenticated / anonymous indeed. Not sure if it is possible. Maybe with the oAuthtoken that works for drive file downloads!
Add a comment...

Bruce Mcpherson
moderator

Tips & tricks  - 
 
If you are using my GasGit libraries for integrating apps script and Github, something changed in the GWT protocol that Apps Script uses to define dependencies during some recent apps script update.

GasGit uses this to figure out which libraries and advanced Google services your script is using and automatically documents it in the dependencies.md file and pulls in the source for any user libraries it has access to.

 It is not documented anywhere how that GWT conversation works (or if it changes), so it's always needs a bit of reverse engineering to figure it out after each update.

Thanks to a bit of detective work by +Spencer Easton, we're back in business again and Advanced Google Services and library dependencies should again get automatically get listed in your Git docs 

It's on Github here https://github.com/brucemcpherson/gasGit

#gde   #googleappsscript   #blogpost   #opensourcesoftware  
7
5
Josi Ayensa's profile photoVonVictor Valentino Rosenchild's profile photo
Add a comment...

Paul Swanson

Tips & tricks  - 
 
Just updated a script of mine - it sends out an automatic email to people who are filling out a Google Form with a summary of their response and also a link to be able to go back and re-Edit their response.

For details, check out my post:
http://www.teacherpaul.org/3327
7
1
Andreas Hofer's profile photoZac Garcia's profile photo김진달's profile photo
4 comments
 
Hi +Andreas Hofer ! Right now, there's no way to redirect a user outside of the Google Form using Google Apps Script. Currently, FormApp only lets you edit the form's formatting and internal flow (along with form responses). There are a couple of options for you, though:
1. Use a script to email the respondent a link to the site you want them to visit
2. Copy the HTML of the form into an HTML Service web app, and use Javascript to redirect the user to the new web page. I'm not sure if this second option will work if you are redirecting to a third party domain.
Add a comment...

Alan Wells

Tips & tricks  - 
 
For debugging HTML, putting a function into the browsers window object seems to allow the "debugger;" line to display the client side JavaScript in the debugger.
For example:

function myFunction() {};

Doesn't seem to allow "debugger;" to display the JavaScript.  But put the function into the window object like this:

window.myFunction = function() {};

Seems to display the code as written when the debugger halts the code.
1
Riël Notermans's profile photoA. Luca B's profile photo
2 comments
 
interesting

will try
Add a comment...

Bruce Mcpherson
moderator

Tips & tricks  - 
 
Just a tiny simple but handy snippet today (it's too hot for more...)
 
Ever had to find the value of a property in an object given a string representing its full key.?

for example, given the string  'properties.key', how to find object.properties.key - 

here's how to use array.reduce() to do it.

'properties.key'.split(".").reduce(function(p, c) {
     return p[c];
   }, {
     properties: {
       key: 'i am the key',
       name: 'the name'
     }
   });
5
Add a comment...

Bruce Mcpherson
moderator

Tips & tricks  - 
 
Here's how you can overlay a plan to a map, and plot points on it from Sheets. If you are starting out with maps add-ons you might find some useful stuff here.

#gde   #googleappsscript   #blogpost   #opensourcesoftware   #googlemaps  
5
3
Riël Notermans's profile photoBruce Mcpherson's profile photoJames Swansburg's profile photoGunther Keim's profile photo
 
This is going to be useful..!
Add a comment...

Hari Shankar Das

Tips & tricks  - 
 
Sharing List Manager for Google Drive released with advanced features
1. Send emails to file and folder collaborators
2. Extract all files/folders to spreadsheet
3. Easily manage collaborators (add-remove editors and viewers)
4. Change editors to viewers and vice versa
Visit http://goo.gl/qAD48X to know more features...
4
Charles Ainslie's profile photoRiël Notermans's profile photo
2 comments
 
Thats quite up to someone that needs it. Coding it yourself takes a few hours. 
Add a comment...

Bruce Mcpherson
moderator

Tips & tricks  - 
 
 
If you have HtmlService apps that create either Canvas or SVG images, here's how you can copy the created image over to your Sheet.

#gde   #googleappsscript   #blogpost  
View original post
3
Daniel Frost's profile photoBruce Mcpherson's profile photo
3 comments
 
+Daniel Frost what you are describing there is a way to include regular js/html/css code in an html template.

Essentially it is equivalent to this...

<?!= HtmlService.createHtmlOutputFromFile('Home.css').getContent(); ?>

The article though is about converting canvas  contents or svg code on the client into image blobs, so that they are consumable by server side code to include in Docs and Sheets.

I do have a separate discussion about the topic you posted about  (different ways of including JS code in html templates)  here 
https://sites.google.com/a/mcpher.com/share/Home/excelquirks/gassnips/sharingframe

Your method is fine too.
Add a comment...

Alan Wells

Tips & tricks  - 
 
I currently have about 15 separate google.script.run calls, but I figured out how to dynamically use different function names and arguments with google.script.run

<script>
  window.onFailure = function(err) {
    alert("server eerror: " + err.message);
  };
  
  window.onSuccess = function(argReturn) {
    alert("Success: " + argReturn);
  };
  
  var whatToPass = 'test HTML';
  var whatFuncToCall = "";
  
  if (1===1) {
    whatFuncToCall = "include";
  } else {
    whatFuncToCall = "somethingElse";
  };
  
  google.script.run
    .withFailureHandler(onFailure)
    .withSuccessHandler(onSuccess)
    [whatFuncToCall](whatToPass);

</script>
4
Add a comment...

Bruce Mcpherson
moderator

Tips & tricks  - 
 
If you are coming to Apps Script from VBA, you might be having a little trouble with JavaScript variable visibility. Here's a couple of tips that might help.

#gde   #googleappsscript   #blogpost  
4
4
김진달's profile photoMichael Roop's profile photo
Add a comment...

Web Apps R&D

Tips & tricks  - 
 
Moment.js 2.10.3
Parse, validate, manipulate, and display dates in JavaScript.

load as Google Apps Script Library

Available under MIT License

https://script.google.com/iboapp.info/d/1RsFFZZvosueH3avP3mQu6CU1TCDKITyrhXlRzfvWIlg698cYLPPJTJer/edit?usp=drive_web

http://momentjs.com/
Format Dates. moment().format('MMMM Do YYYY, h:mm:ss a'); moment().format('dddd'); moment().format("MMM Do YY"); moment().format('YYYY [escaped] YYYY'); moment().format();. Relative Time. moment("20111031", "YYYYMMDD").fromNow(); moment("20120620", "YYYYMMDD").fromNow(); moment().startOf('day').
1
Add a comment...

Bruce Mcpherson
moderator

Tips & tricks  - 
 
Here's a very useful d3.js vizualtion to dig into which Apps Script projects are using which versions of which libraries. It works alongside my GasGit project for gettings Apps Script source to GitHub, so if you use that, you'll probably want this too.

#gde   #googleappsscript   #blogpost   #opensourcesoftware   #d3  
9
3
Dave Mac's profile photoBryan Scott's profile photo
Add a comment...

Web Apps R&D

Tips & tricks  - 
 
You should strive for a sustainable solution
be careful with the Google Apps Script functional examples

Having seen this at +Autodesk it inspired us to share an important experience with you. Some of you will not aim for a solution that can be adapted to new requirements without putting the running apps at risk. But if you are keen to master Google Apps Script in order to deliver a solution for a more complicated workflow, you may benefit from this hint.

First have a look at the image. Would you cut the cord, blend a washing machine with a bicycle ergometer and present the design to the public? There is a ton of problems to be solved prior to a comercial product, but the most important problem is acceptance by the customer and the second problem is to be faster than competition. 

How can you test acceptance without exposing your solution in public?

With the implementation style of the exmples you can implement the working prototype of many Google Apps Script applications, but do not expect it to be easy to change them. Just write something down, show it, collect feedback and make sure there is a demand.

As soon as you know how the app should work and look like, make an object class design, even for the smallest object such as a folder name or a file name if you e.g. apply specific naming conventions. 

We lost momentum because we tried to deploy a solution based on libraries and functions. Encapsulation is mandatory and without inheritance, it will be very difficult to adopt to changing requirements.

If you are interested in the details of what we found out, just leave a comment with a specific question to this post.
Master multitaskers find creative ways to maximise time efficiency by doing seemingly unrelated things all at once - a little like the Bike Washing Machine
7
1
Juan Salvador Pérez's profile photo
Add a comment...