Skip to content

Instantly share code, notes, and snippets.

View peterknolle's full-sized avatar
💭
🎅

Peter Knolle peterknolle

💭
🎅
View GitHub Profile
@peterknolle
peterknolle / RerenderNoAction.cls
Last active December 12, 2015 08:18
Some Visualforce and Apex experimentation with rerendering
public with sharing class RerenderNoAction {
public RerenderNoAction() {
viewMeCnt = 0;
}
public Integer viewMeCnt { get; set; }
public String parentOpt { get; set; }
public List<SelectOption> getParentOptions() {
List<SelectOption> opts = new List<SelectOption>();
@peterknolle
peterknolle / RemotingController.cls
Last active March 6, 2020 21:18
Visualforce Remoting with Relationships
global class RemotingController {
// Assumes two custom objects: Test_Object__c with lookup to Test_Object_2__c
@RemoteAction
global static void UpsertA(Test_Object__c obj1) {
upsert obj1.Test_Object_2__r;
obj1.Test_Object_2__c = obj1.Test_Object_2__r.Id;
upsert obj1;
}
@peterknolle
peterknolle / AnalyticsController.cls
Created January 25, 2014 22:59
Apex Analytics API and Report Chart Component
public with sharing class AnalyticsController{
public List<SelectOption> availableReports { get; set; }
public Id reportId { get; set; }
public Map<String, List<SelectOption>> availableDataTypeFilterOperators { get; set; }
public List<ColumnFilter> availableColumnFilters { get; set; }
public AnalyticsController() {
availableReports = retrieveAvailableReports();
availableDataTypeFilterOperators = retrieveAvailableDataTypeFilterOperators();
@peterknolle
peterknolle / preChat.html
Created January 25, 2014 23:15
Live Agent Pre-Chat API in Pre-Chat Form for Service Cloud
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
(function() {
function handlePageLoad() {
var endpointMatcher = new RegExp("[\\?\\&]endpoint=([^&#]*)");
document.getElementById('prechatForm').setAttribute('action',
decodeURIComponent(endpointMatcher.exec(document.location.search)[1]));
}
@peterknolle
peterknolle / BubbleChart2Controller.cls
Created February 9, 2014 19:17
Analytics API in Apex and Google Visualization API - Bubble Chart
public with sharing class BubbleChart2Controller{
public String deafultFromDate { get; set; }
public String defaultThroughDate { get; set; }
private static final String REPORT_ID = '00Ox0000000hEzq';
public BubbleChart2Controller() {
// Default to the current year.
// These instance variables are only used to
// populate the default values on the inputs.
@peterknolle
peterknolle / AsyncReportController.cls
Created February 17, 2014 02:40
Asynchronous Reports with the Analytics API in Apex
public with sharing class AsyncReportController {
public List<SelectOption> availableReports { get; set; }
public Id reportId { get; set; }
public Id instanceId { get; set; }
public Boolean reportIsRunning { get; set; }
private transient Reports.ReportResults reportResults;
public AsyncReportController() {
availableReports = retrieveAvailableReports();
@peterknolle
peterknolle / remoteObjectNodes.page
Last active August 7, 2018 09:07
Visualforce Remote Objects and jsTree jQuery plugin
<apex:page >
<!-- download the jstree from jstree.com and upload the dist directory as a static resource -->
<link href="{!URLFOR($Resource.jsTree, 'themes/default/style.min.css')}" rel="stylesheet" />
<script src="{!URLFOR($Resource.jsTree, 'libs/jquery.js')}"></script>
<script src="{!URLFOR($Resource.jsTree, 'jstree.min.js')}"></script>
<script src="{!URLFOR($Resource.jsTree, 'jstree.min.js')}"></script>
<!--
Change the remoteObjectModel name="Account and
@peterknolle
peterknolle / JoinController.cls
Created May 7, 2014 02:20
Google Visualization API Joins in Visualforce
public with sharing class JoinController {
// The from and through dates are hard-coded for simplicity's sake.
// Should change to parameters or input or something else.
public String getPageViewsJson() {
List<Page_View_Summary__c> pvs = [
SELECT Date__c, Number_of_Views__c
FROM Page_View_Summary__c
WHERE Date__c >= 2014-04-01
AND Date__c <= 2014-04-30
<apex:page controller="jTableAccountsController">
<link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/redmond/jquery-ui.css" rel="stylesheet" type="text/css" />
<link href="{!URLFOR($Resource.jtable, 'jtable/themes/jqueryui/jtable_jqueryui.min.css')}" rel="stylesheet" type="text/css" />
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"/>
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"/>
<apex:includeScript value="{!URLFOR($Resource.jtable, 'jtable/jquery.jtable.min.js')}"/>
@peterknolle
peterknolle / DescribeController.cls
Last active September 5, 2019 18:31
Using Apex Describe to Find Object Paths
public with sharing class DescribeController {
public Graph theGraph { get; set; }
public List<SelectOption> nodeOptions { get; set; }
public String sourceNodeStr { get; set; }
public String destNodeStr { get; set; }
public transient List<GraphPath> paths { get; set; }
public transient String json { get; set; }