Skip to content

Instantly share code, notes, and snippets.

View keirbowden's full-sized avatar

Keir Bowden keirbowden

View GitHub Profile
@keirbowden
keirbowden / BarcodeSF1Ctrl
Created March 15, 2014 12:19
Visualforce controller with a JavaScript remoting method to retrieve a matching record after scanning a barcode.
public with sharing class BarcodeSF1Ctrl
{
@RemoteAction
public static String getRecordFromBarcode(String bcStr)
{
String result;
List<String> eles=bcStr.split(':');
String code=eles[1].trim();
List<Account> accs=[select id, Barcode__c from Account where Barcode__c=:code];
@keirbowden
keirbowden / CheckAttachmentSize.page
Created September 5, 2014 16:41
Visualforce page that checks the size of a file selected for upload
<apex:page standardController="Account" extensions="AddAttachmentExt">
<apex:includeScript value="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.9.1.min.js"/>
<apex:form>
<apex:sectionHeader title="{!Account.name} Attachments" />
<apex:pageBlock mode="maindetail">
<apex:pageBlockSection title="Existing Attachments" columns="1">
<apex:PageBlockTable value="{!Account.Attachments}" var="attach">
<apex:column value="{!attach.Name}" />
<apex:column headerValue="Length (bytes)" value="{!attach.BodyLength}" />
<apex:column headerValue="Owner" value="{!attach.Owner.Name}" />
@keirbowden
keirbowden / AddAttachmentExt.cls
Created September 5, 2014 16:43
Extension controller to save an attachment associated with a record encapsulated in the standard controller
public with sharing class AddAttachmentExt
{
private ApexPages.StandardController stdCtrl;
public Attachment att {get; set;}
public AddAttachmentExt(ApexPages.StandardController inStd)
{
stdCtrl=inStd;
att=new Attachment();
}
@keirbowden
keirbowden / TableSortingCtrl.cls
Last active August 29, 2015 14:06
Custom controller for the table sorting blog post
public with sharing class TableSortingCtrl {
public List<Account> accounts {get; set;}
public TableSortingCtrl()
{
accounts=[select id, CreatedDate, Name, BillingStreet,
BillingState, BillingCity,
BillingPostalCode, BillingCountry
from Account
where BillingPostalCode!=null
@keirbowden
keirbowden / TableSorter.page
Created September 20, 2014 14:51
Demo page for Visualforce and tablesorter
<apex:page sidebar="true" controller="TableSortingCtrl">
<apex:includeScript
value="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" />
<apex:includeScript
value="//cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.17.8/js/jquery.tablesorter.min.js" />
<apex:stylesheet
value="//cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.17.8/css/theme.blue.css" />
<apex:datatable value="{!accounts}" var="acc" id="accsTable" styleclass="tablesorter">
<apex:column headerValue="Created">
@keirbowden
keirbowden / RequiredCtrl.cls
Created September 27, 2014 07:31
Action Region, Required Fields and HTML5 Controller
public with sharing class RequiredCtrl
{
public List<Row> rows {get; set;}
public String name {get; set;}
public Account acc {get; set;}
public RequiredCtrl()
{
rows=new List<Row>();
rows.add(new Row());
@keirbowden
keirbowden / RequiredHTML5.page
Created September 27, 2014 07:33
Action Region, Required Field and HTML5 Page
<apex:page controller="RequiredCtrl" tabstyle="Account" doctype="html-5.0">
<apex:pageMessages id="msgs"/>
<apex:form>
<apex:pageBlock mode="maindetail">
<apex:pageBlockButtons location="top">
<apex:commandButton value="Save" action="{!save}" />
</apex:pageBlockButtons>
<apex:pageBlockSection title="Account Information">
<apex:pageBlockSectionItem>
<apex:outputlabel value="Name"/>
@keirbowden
keirbowden / gist:a1e624fbc596f0b71ea4
Created April 18, 2015 14:41
Accounts List Lightning Component
<aura:component controller="AccountsListController" implements="flexipage:availableForAllPageTypes">
<link href="/resource/Bootstrap_3_3_2/bootstrap-3.3.2-dist/css/bootstrap.min.css" rel="stylesheet" />
<link class="user" href="/resource/Bootstrap_3_3_2/bootstrap-3.3.2-dist/css/bootstrap-theme.min.css"
rel="stylesheet" type="text/css" />
<aura:attribute name="accounts" type="Account[]" />
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<div class="container-fluid">
<div class="row-fluid">
@keirbowden
keirbowden / gist:c99015c1006f7a14f08d
Created April 18, 2015 15:23
Accounts List JavaScript Component
<apex:component >
<script>
var accsListCtrl={
// renders the HTML to display the supplied accounts in bootstrap panels
renderAccs : function(accounts) {
var markup='';
$.each(accounts, function(idx, acc) {
markup+= ' <div class="row-fluid"> \n' +
' <div class="col-xs-12 fullwidth"> \n' +
' <div class="panel panel-primary"> \n' +
@keirbowden
keirbowden / RWDCaseApp.app
Last active August 29, 2015 14:20
Lightning Application to Retrieve Cases and Iterate
<aura:application controller="CasesController">
<aura:attribute type="Case[]" name="cases" description="casesToIterate" />
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:iteration items="{!v.cases}" var="case">
<c:RWDCase case="{!case}" />
</aura:iteration>
</aura:application>