Skip to content

Instantly share code, notes, and snippets.

@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; }
@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 / 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 / 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 / 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 / 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 / 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>
<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.', '')}';