Skip to content

Instantly share code, notes, and snippets.

<apex:page controller="ZipOpportunities" showHeader="true" sidebar="true">
<head>
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js"></script>
<script type="text/javascript">
var j$ = jQuery.noConflict();
j$(document).ready(function() {
var accountId = '{!accountId}'; // Get Account Id from the controller
public with sharing class ZipOpportunities {
public String accountId {get; set;}
public String zipFileName {get; set;}
/**
* Query for the Account using the parameter in the query string
* Set the filename for the ZIP file
**/
public ZipOpportunities() {
@redryan
redryan / ChatterPage
Last active November 19, 2015 17:19
Salesforce Chatter embedded in an IFrame
<apex:page controller="ChatterPage" showHeader="false" sidebar="false" standardStylesheets="true">
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script>
// Capture all clicks on <a> elements and change the URL for the whole window
// Some <a> elements are used for JavaScript function calls, so only capture them
// when the URL starts with the / character.
jQuery(document).ready(function($) {
$('#chatter-container').contents().on('click', 'a', function(e) {
if($(this).attr('href').charAt(0) == '/') {
app.get('/accounts', function(req, res) {
// if auth has not been set, redirect to index
if (!req.session.accessToken || !req.session.instanceUrl) { res.redirect('/'); }
var query = 'SELECT id, name FROM account LIMIT 10';
// open connection with client's stored OAuth details
var conn = new jsforce.Connection({
accessToken: req.session.accessToken,
instanceUrl: req.session.instanceUrl
});
/* SF OAuth request, redirect to SF login */
app.get('/oauth/auth', function(req, res) {
res.redirect(oauth2.getAuthorizationUrl({scope: 'api id web'}));
});
/* OAuth callback from SF, pass received auth code and get access token */
app.get('/oauth/callback', function(req, res) {
var conn = new jsforce.Connection({oauth2: oauth2});
var code = req.query.code;
conn.authorize(code, function(err, userInfo) {
// Salesforce OAuth2 client information
var oauth2 = new jsforce.OAuth2({
clientId: ‘client id string’
clientSecret: ‘client secret string’,
redirectUri: 'callback url'
});