Skip to content

Instantly share code, notes, and snippets.

Avatar

Patrick Connelly pcon

View GitHub Profile
@pcon
pcon / APIUtils.java
Last active Sep 28, 2015
Web-services examples in Salesforce
View APIUtils.java
/**
* This class is a utility class for WebServices and other API classes
*/
global with sharing class APIUtils {
global final static Integer STATUS_OK = 200;
global final static Integer STATUS_CREATED = 201;
global final static Integer STATUS_ACCEPTED = 202;
global final static Integer STATUS_BAD = 400;
global final static Integer STATUS_FORBIDDEN = 403;
global final static Integer STATUS_NOTFOUND = 404;
@pcon
pcon / MyObjectTrigger.java
Created Dec 15, 2011
Classifying triggers in Salesforce
View MyObjectTrigger.java
public class MyObjectTrigger {
private final Map<Id, MyObject__c> oldMap;
private final Map<Id, MyObject__c> newMap;
private final List<MyObject__c> newObjs;
private final Boolean isInsert;
private final Boolean isUpdate;
private final Boolean isDelete;
private final Boolean isBulk;
/**
@pcon
pcon / .vimrc
Created Feb 9, 2012
salesforce vim config options
View .vimrc
" General stuff
set nocompatible
filetype on
set background=light
syntax on
" don't make it look like there are line breaks where there aren't:
set nowrap
@pcon
pcon / CaseTrigger.java
Last active Oct 2, 2015
Salesforce Static variable with dynamic assignment
View CaseTrigger.java
MyObject__c obj = MyObjectUtils.myObjectMap.get('Foo');
@pcon
pcon / template.java
Created May 22, 2012
Pcon trigger template.java
View template.java
public class OrderTrigger {
private final Map<Id, Order__c> oldMap;
private final Map<Id, Order__c> newMap;
private final List<Order__c> newObjs;
private final Boolean isInsert;
private final Boolean isUpdate;
private final Boolean isDelete;
private final Boolean isBulk;
/**
View scheduledMonthly.java
/**
* To schedule the monthly reconciliation:
* NOTE: It should run at midnight on the first of every month on it's own, but if you make
* changes and need to requeue run the command below from the developer's console
*
* scheduledMonthly.scheduleIt();
*/
global class scheduledMonthly implements Schedulable {
public static String CRON_EXP = '0 0 0 1 * ? *';
@pcon
pcon / ServiceRequestTrigger.java
Created May 30, 2012
Checking previous status != 'In Review' and then switched to 'In Review' - field expression now allowed for generic SObject line 33
View ServiceRequestTrigger.java
public class ServiceRequestTrigger {
private final Map<Id, Service_Request__c> oldMap;
private final Map<Id, Service_Request__c> newMap;
private final List<Service_Request__c> newObjs;
private final Boolean isInsert;
private final Boolean isUpdate;
private final Boolean isDelete;
private final Boolean isBulk;
/**
@pcon
pcon / ServiceRequestTrigger.java
Created May 31, 2012
Checking previous status != 'In Review' and then switched to 'In Review' - field expression now allowed for generic SObject line 33
View ServiceRequestTrigger.java
public class ServiceRequestTrigger {
private final Map<Id, Service_Request__c> oldMap;
private final Map<Id, Service_Request__c> newMap;
private final List<Service_Request__c> newObjs;
private final Boolean isInsert;
private final Boolean isUpdate;
private final Boolean isDelete;
private final Boolean isBulk;
/**
@pcon
pcon / swap.sh
Created Jul 3, 2012
swap function
View swap.sh
function swap() {
TMP_NAME="TMP_$RANDOM"
mv "$1" "/tmp/$TMP_NAME" && mv "$2" "$1" && mv "/tmp/$TMP_NAME" "$2"
}
@pcon
pcon / CaseEdit_ControllerExtension.java
Last active Oct 7, 2015
Dynamic dependent picklists
View CaseEdit_ControllerExtension.java
global with sharing class CaseEdit_ControllerExtension {
private final Id recordId;
private final Case record;
private final ApexPages.StandardController controller;
public Case_ControllerExtension(ApexPages.StandardController stdController) {
this.controller = stdController;
this.recordId = this.controller.getId();
this.record = [
select Product__c,