Skip to content

Instantly share code, notes, and snippets.

<apex:page docType="html-5.0" sidebar="false" showHeader="false"
standardStylesheets="false" cache="true">
<html lang="en">
<head>
<meta charset="utf-8"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript">
var SESSION_ID = '{!$Api.Session_ID}';
var serverURL = '{!SUBSTITUTE(SUBSTITUTE(LEFT($Api.Partner_Server_URL_210, FIND( '/services', $Api.Partner_Server_URL_260)), 'visual.force', 'salesforce'), 'c.', '')}';
@sohalloran
sohalloran / VisualforceDrilldownChart.page
Last active April 4, 2018 21:07
Visualforce Charting with drill down when clicking on chart sections/bars
<apex:chart height="300" width="300" data="{!data}”>
<apex:axis type="Category" position="bottom" fields="ctype">
<apex:chartLabel rotate="270"/>
</apex:axis>
<apex:axis type="Numeric" position="left" fields="cval"/>
<apex:barSeries axis="left" orientation="vertical" xField="ctype" yField="cval">
<apex:chartTips rendererFn="renderer"/>
</apex:barSeries>
</apex:chart>
@sohalloran
sohalloran / JSONPify Example
Last active December 12, 2015 05:28
JSONPify Example - Example of adding JSONP support to a REST API via a proxy node.js service
// Client JS
$.ajax({
cache: false,
dataType: 'jsonp',
url: 'https://MY_JSONP_SERVER/jsonp?sid='+SID_HERE+'&path='+REST_RESOURCE,
success: function(data){
console.log(JSON.stringify(data));
}
});
@sohalloran
sohalloran / postMessage() Example
Created February 6, 2013 13:37
postMessage() Example
// Client iframe container
<iframe id="xdwin" width="0px" height="0px" src="PROXY_SERVER/xd"></iframe>
<script>
window.addEventListener('message',function(event) {
if(event.origin !== ALLOWED_ORIGIN) return;
console.log(JSON.stringify(event.data));
},false);
function postMessage(e) {
var win = document.getElementById("xdwin").contentWindow;
@sohalloran
sohalloran / OAuth Tester
Created March 22, 2013 16:59
OAuth Tester - user-agent flow
<!--// MAIN PAGE //-->
<!DOCTYPE html>
<html>
<head>
<title>Oauth Tester</title>
<link rel="stylesheet" href="https://app.divshot.com/css/bootstrap.css">
<script type="text/javascript">
var CLIENT_ID = '';
var CALLBACK_URL = '';
@sohalloran
sohalloran / AESDecryptExample.php
Last active December 28, 2015 07:39
PHP AES decryption example Can be tested here: http://phpfiddle.org/main/code/7465540
<?php
function decrypt_data($data, $iv, $key) {
$cypher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
if(is_null($iv)) {
$ivlen = mcrypt_enc_get_iv_size($cypher);
$iv = substr($data, 0, $ivlen);
$data = substr($data, $ivlen);
}
@sohalloran
sohalloran / searchAccounts.vf
Last active December 28, 2015 22:39
Example of Search Before Create pattern using a Visualforce page
<apex:page standardController="Account" extensions="searchAccounts" sidebar="false" >
<apex:sectionHeader title="Convert Prospect" subtitle="Account Search and Create"/>
<apex:form id="form">
<apex:pageBlock id="crit_block">
<apex:pageblockSection columns="7" id="crit">
<apex:pageBlockSectionItem >
<apex:outputLabel value="Account Name:"/>
<apex:inputText value="{!name}" onkeypress="return noenter();"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem id="buttons">
@sohalloran
sohalloran / searchAccounts.cls
Created November 21, 2013 00:12
Example Search Before Create Apex Controller. This is a sample implementation which interacts with a Transaction Hub which have 'search' and 'publish' REST APIs which return the results in JSON format.
public without sharing class searchAccounts {
public String name { get; set; }
public String op { get; set; }
public String mdId { get; set; }
public String accId {get; set;}
public Account acc {get; set;}
public List<Acc> accs { get; set; }
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="React by Example - Components">
<link href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet" type="text/css" />
<script src="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<script src="http://fb.me/react-with-addons-0.14.3.js"></script>
<script src="http://fb.me/react-dom-0.14.3.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
@sohalloran
sohalloran / Email2Case.apex
Last active July 5, 2017 17:29
Email2Case
global class Email2Case implements Messaging.InboundEmailHandler {
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
String body = email.plainTextBody;
Case newCase = new Case();
newCase.SuppliedEmail = parse(body,'EMAIL:',false);
newCase.SuppliedName = parse(body,'LAST NAME:',false);
newCase.Description = 'Accepted Terms: ' + parse(body,'ACCEPTED TERMS',false) + ' Receive Further Info: ' + parse(body,'RECEIVE FURTHER INFO',false) + ' ' + parse(body,'MESSAGE:',true);
newCase.Subject = 'Email from ' + parse(body,'EMAIL:',false);
insert newC