You need to sign in to do that
Don't have an account?
Export the contacts using google Spreadsheet
Hi All
I need to export the contacts as google spread sheet. for that I wrote the VF page. but it is not working.
my page is
<apex:page standardController="contact"><script type="text/javascript" src="/js/functions.js"></script><script src="/soap/ajax/10.0/connection.js"></script><script type="text/javascript">if (!top) var top={};top.retURL = "/003";var g; function init() { sforce.debug.println = log; sforce.debug.trace = false;
g = new GoogleSpreadsheet(); g.authSubLogin(top); var query = 'Select FirstName, LastName, Phone From Contact Limit 5'; var queryResult = sforce.connection.query(query, queryCallback );}
function queryCallback(queryResult) { var cellFeedUrl = getCellFeedUrl(); var contacts = queryResult.getArray('records'); for (var i=0; i<contacts.length; i++) { g.updateCell(cellFeedUrl, i+1, 1, contacts[i].LastName + ", " + contacts[i].FirstName); g.updateCell(cellFeedUrl, i+1, 2, contacts[i].Phone); }
// Return to the contacts page jumpback(); }
function getCellFeedUrl() { var SPREADSHEET_TITLE = 'Salesforce.com Contacts'; var WORKSHEET_REL = 'http://schemas.google.com/spreadsheets/2006#worksheetsfeed'; var CELLSFEED_REL = 'http://schemas.google.com/spreadsheets/2006#cellsfeed';
// Query to find the spreadheet called "Salesforce.com Contacts" var spreadsheets = g.getFeed(g.feeds + '/spreadsheets/private/full'); var entries = g.getEntryList(spreadsheets); for (var e in entries) { if (g.getTitle(entries[e]) == SPREADSHEET_TITLE) { var worksheetsFeedUrl = g.link(entries[e],WORKSHEET_REL); var worksheets = g.getFeed(worksheetsFeedUrl); var worksheetEntries = g.getEntryList(worksheets); return g.link(worksheetEntries[0], CELLSFEED_REL); } }}
function log(string) { var doc = document.getElementById("log-output"); doc.innerHTML += string + '<br>';}
function jumpback() { retURL = top.retURL; // one more override if ( window.opener && typeof(window.opener) == 'object' ) { // deal with popup setTimeout("window.close();",100); window.opener.location.href = retURL; } else { // normal parent close window.parent.parent.location.href = retURL; }}</script> <!--{!INCLUDE($SControl.gspreadsheet_snippet)}-->
<body onload="init();">
<img src="/img/icon/home32.png" height="64" width="64" /> <img src="/img/waiting_dots.gif" alt="Please wait..." title="Please wait..." height="25" width="196" /> <img src="http://docs.google.com/images/doclist/logo_docs.gif" /> <p><h3>Exporting contacts to Google Spreadsheets, please wait...</h3></p>
</body></apex:page>
Please help me.
Thanks
Anu.....
That code is not readable. Post it in a code block.
Hi Wizard
This code is running. I am getting the contacts in Eclipse.but the contacts are not visible in Google spread sheet. How can I handle this.
Please help me
Thanku
Anu