Thursday, March 12, 2015
Google Drawings Support added to Documents List API
Currently, we allow importing Drawings from WMF files. Drawings can be exported as PDF, JPEG, PNG, and SVG images.
This has been a feature requested by many users, so we’re happy to fulfil those requests. The release of this feature has been done in stages. You may have noticed that Drawings started showing up in list feeds a few months ago, but our most recent release marks full support for Drawings.
These features are only available in version 3.0 of the Documents List API. Users can read the updated documentation and the release notes for information on using these new features of the API. As always, if you have any questions, please visit the Documents List API support forum.
Posted by Vic Fryzel, Google Apps Team
Want to weigh in on this topic? Discuss on Buzz
5 things you didnt know you could do with the Google Drive API
Have you tried using the Google Drive API? If so, you’re aware that it allows you to programmatically manage a user’s Google Drive and build applications to manipulate files stored in the user’s account. However, the API might still be capable of doing a few things you didn’t know about. Here is a list of five specific use cases and how each of them can be addressed with the API.
1) Sharing a file with the world
When a file in Google Drive is shared publicly, it can be downloaded without authentication at the URL provided by the API in the webContentLink field of the Files resource. To retrieve that value, send a GET request to retrieve the file metadata and look for the webContentLink element in the JSON response, as in the following example:
{
"kind": "drive#file",
"id": "0B8E...",
"etag": "WtRjAP...",
"selfLink": "https://www.googleapis.com/drive/v2/files/0B8E...",
"webContentLink": "https://docs.google.com/a/google.com/uc?id=0B8E...",
...
}
2) Granting comment-only access to a user
When setting permissions for a file with the Drive API, you can choose one of owner, writer and reader as the value for the role parameter. The Drive UI also lists another role, commenter, which is not allowed for that parameter.
In order to grant comment-only access to a user with the Drive API, you have to set the role parameter to reader and include the value commenter in the list of additionalRoles, as in the following example:
{
"kind": "drive#permission",
...
"role": "reader",
"additionalRoles": [
"commenter"
],
...
}
3) Listing all files in the root folder
It is possible to restrict the list of files (and folders) returned by the Drive API by specifying some search criteria in the q query parameter. Each file has a parents collection listing all folders containing it, and the root folder in Google Drive can be conveniently addressed with the alias ‘root’. All you need to do to retrieve all files in that folder is add a search query for element with ‘root’ in their parents collection, as in the following example:
GET https://www.googleapis.com/drive/v2/files?q=root in parents
Remember to URL-encode the search query for transmission unless you are using one of the available client libraries.
4) Finding how much quota is available in the user’s account
Your application might need to know if users have enough available quota to save a file, in order to handle the case when they don’t. Quota information is available in the About feed of the Drive API:
{
"kind": "drive#about",
...
"quotaBytesTotal": "59055800320",
"quotaBytesUsed": "14547272",
"quotaBytesUsedInTrash": "511494",
...
}
The feed includes three values related to quota management: quotaBytesTotal, quotaBytesUsed and quotaBytesUsedInTrash. The first value indicates the total amount of bytes available to the user (new accounts currently get 5GB for free) while the second one tells how many of those bytes are in use. In case you need to get more free space, you can use the last value to know how many bytes are used by files that have been trashed. An application might use this value to recommend emptying the trash bin before suggesting to get additional storage.
5) Discovering if one of the user’s apps can open a file
Google Drive allows users to store any kind of file and to install applications to open file types that are not directly supported by the native Google applications. In case you need to know what applications are installed and what file types each of them can open, you can retrieve the Apps feed and look for the primaryMimeTypes and secondaryMimeTypes elements for supported MIME types or primaryFileExtensions and secondaryFileExtensions for file extensions:
{
"kind": "drive#app",
"name": "Pixlr Editor",
...
"primaryMimeTypes": [
"image/psd",
"image/pxd",
"application/vnd.google-apps.drive-sdk.419782477519"
],
"secondaryMimeTypes": [
"image/png",
"image/jpeg",
"image/gif",
"image/bmp"
],
"primaryFileExtensions": [
"pxd",
"psd"
],
"secondaryFileExtensions": [
"jpg",
"png",
"jpeg",
"bmp",
"gif"
],
…
}
Note: to access the Apps feed you have to request access to the https://www.googleapis.com/auth/drive.apps.readonly OAuth scope.
![]() | Claudio Cherubino profile | twitter | blog Claudio is an engineer in the Google Drive Developer Relations team. Prior to Google, he worked as software developer, technology evangelist, community manager, consultant, technical translator and has contributed to many open-source projects. His current interests include Google APIs, new technologies and coffee. |
Tuesday, March 10, 2015
Integrating Google Docs with Salesforce com using Apps Script
Editors Note: Ferris Argyle is going to present Salesforce Workflow Automation with Google Spreadsheet and Apps Script at Cloudforce. Do not miss Ferriss talk - Saurabh Gupta
As part of Googles Real Estate and Workplace Services (REWS) Green Team, the Healthy Materials program is charged with ensuring Google has the healthiest workplaces possible. We collect and review information for thousands of building materials to make sure that our offices are free of formaldehyde, heavy metals, PBDEs and other toxins that threaten human health and reduce our productivity.
A Case for using Google Docs and Salesforce.com
My team, as you might imagine, has a great deal of data to collect and manage. We recently implemented Salesforce.com to manage that data, as it can record attributes of an object in a dynamic way, is good at tracking correspondence activity and allows for robust reports on the data, among many other functions.
We needed Saleforce.com to integrate with our processes in Google Apps. We wanted to continue collecting data using a Google Docs form but needed it integrated with Salesforce.com because we:
- Liked the way the form looked and functioned
- Wanted to retain continuity for our users, including keeping the same URL
- Wanted a backup of submissions
And this is where Google Apps Script came to our rescue. We found that we could use Google Apps Script to create a new Case or Lead in Salesforce.com when a form is submitted through our Google Docs form. This allowed us to continue using our existing form and get our data directly and automatically into Salesforce.com.
Google Docs + Apps Script + Salesforce.com = Integrated Goodness!
Salesforce.com has two built-in options for capturing data online - Cases and Leads. Google Docs Forms can capture data for both of them. Set up your Case or Lead object with the desired fields in Salesforce.com. The next step is to generate the HTML for a form. You will use the IDs in the Salesforce.com-generated HTML when writing your Google Apps script.
A) Getting the HTML in Salesforce.com:
1. Login to Salesforce.com and go to Your Name > Setup > Customize > Leads or Self-Service (for Cases) > Web-to-Lead or Web-to-Case
2. Make sure Web-to-Lead/Web-to-Case is enabled. Click on Edit (Leads) or Modify (Cases) and enable if it is not.
3. Click on the Create Web to Lead Form button (for Leads) or the Generate the HTML link (for Cases)
4. Select the fields you want to capture and click Generate. Save the HTML in a text file. You can leave Return URL blank

B) Setting up Google Apps Form/Spreadsheet:
Create your form and spreadsheet (or open up the one you already have and want to keep using). This is very easy to do. Go to your Docs and click on Create to open a new form. Use the form editor to add the desired fields to your form- theyll show up as column headings in the corresponding spreadsheet. When someone fills out your form, their answers will show up in the right columns under those headings.
C) Writing the Google Apps Script:
The script is set up to take the data in specified cells from the form/spreadsheet and send it into designated fields in your Salesforce.com instance (identified by the org id in the HTML generated above). For example, the form submitters email is recorded through the form in one cell, and sent into the email field in either the Lead or Case object in Salesforce.com.
1. Create a new script (Tools > Script Manager > New).
2. Write the script below using the pertinent information from your Salesforce.com-generated code (shown further down).
function SendtoSalesforce() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var row = sheet.getLastRow();
var firstname = sheet.getRange(row, 2).getValue();
var lastname = sheet.getRange(row, 3).getValue();
var email = sheet.getRange(row, 4).getValue();
var company = sheet.getRange(row, 5).getValue();
var custom = sheet.getRange(row, 6).getValue();
var resp = UrlFetchApp
.fetch(
https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8,
{
method: post,
payload: {
orgid : 00XXXXXXXX,
first_name : firstname,
last_name : lastname,
email : email,
company : company,
00YYYYYYYY : custom,
external : 1
}
});
Logger.log(resp.getContentText());
}
Define your variables by directing the script to the correct cell (row, column number). Then in the payload section, match the field id from your Salesforce.com HTML (red) to the variable you defined (blue). For example, the email address of the submitter is defined as variable email, can be found in the 4th column of the last row submitted, and the id for that field in Salesforce.com is email.

Note that any custom fields youve created will have an alpha-numeric id.
3. Save your script and do a test run.
D) Wiring Script to a Form Submission.
To send your data automatically into Salesforce.com, you need to set a trigger that will run the script every time a form is submitted. To do this, go to your script and click Resources>Current scripts triggers.
1. Create a Trigger for your function so that it runs when a form is submitted.

2. Post the link to your form on your website, send it in an email, link to it on G+, etc. Get it out there!
Thats it! Now when someone submits a form, the information will come into your spreadsheet, and then immediately be sent into Salesforce.com. You can adjust your Salesforce.com settings to create tasks when the information comes in, send out an auto-response to the person filling out the form and set up rules for who is assigned as owner to the record. Youll also have the information backed up in your spreadsheet.
This has been a great solution for our team, and we hope others find it useful as well!
![]() | Beth Sturgeon Beth Sturgeon is a member of Googles Green Team in Mountain View, which makes sure that Googles offices are the healthiest, most sustainable workplaces around. Prior to Google, she had a past life as a wildlife researcher. |

