Skip to content

Instantly share code, notes, and snippets.

View pchittum's full-sized avatar

Peter Chittum pchittum

  • Freelance
  • UK
  • 21:22 (UTC -12:00)
View GitHub Profile
@pchittum
pchittum / helper method
Last active May 24, 2017 21:42
bulk notifications for enterprise messaging
public static void publishNotifications(List<String> messages){
List<Notification__e> notifications = new List<Notification__e>();
for (String message: messages) {
notifications.add(new Notification__e(Message__c = message));
}
List<Database.SaveResult> results = EventBus.publish(notifications);
//process results
@pchittum
pchittum / Apex Test Run Output
Created May 24, 2017 10:13
Output from Salesforce DX Apex Test Run
pchittum-ltm:dreamhouse-wt pchittum$ sfdx force:apex:test:run -u dreamhouse -d deploy -r human -c
Listening for results
Invoking Apex tests using dreamhouse...
Started async test run job: 7075800002GiN0g
Test run id written to deploy/test-run-id.txt
Processing event for job 7075800002GiN0gAAF
Processing event for job 7075800002GiN0gAAF
Processing event for job 7075800002GiN0gAAF
Processing event for job 7075800002GiN0gAAF
Processing event for job 7075800002GiN0gAAF
@pchittum
pchittum / Notes on Bulk Triggers Unit
Created March 1, 2017 13:45
Trailhead code critiques
//alternative or additional query to show sub query that is not unbounded
for(Account a : [SELECT Id,Name
FROM Account
WHERE Id IN :Trigger.New
AND Id NOT IN (SELECT AccountId
FROM Opportunity
WHERE AccountId in : Trigger.New)]){
System.debug(a);
}
@pchittum
pchittum / Fizz Buzz Elixir
Last active February 24, 2017 23:32
Fizz Buzz
for n <- 1..20 do
cond do
rem(n, 15) == 0 -> "fizzbuzz"
rem(n, 5) == 0 -> "buzz"
rem(n, 3) == 0 -> "fizz"
true -> n
end
end
@pchittum
pchittum / This works.
Created November 19, 2015 10:56
Rerender Example in Visualforce
<apex:page standardController="Position__c" title="Sample Position Layout Page" showHeader="true" sidebar="true" >
<apex:sectionHeader title="{!$ObjectType.Position__c.label} Edit" subtitle="New Position"/>
<chatter:feedWithFollowers entityId="{!Position__c.id}"/>
<apex:form id="theForm">
<!--this is the level I am rerendering at...including all sections and children-->?
<apex:pageBlock title="Position Detail" mode="edit" id="thePageBlock">
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Cancel" action="{!cancel}" immediate="true"/>
@pchittum
pchittum / Lightning Component Apex Service
Created October 21, 2015 11:19
Using Lightning Components force:outputField or force:inputField
public with sharing class AccountViewEditService {
@AuraEnabled
public static Account fetchAccount(Id acctId){
Account newAcct;
try {
System.debug('querying for account id: ' + acctId);
newAcct = [SELECT Id, Name, Type, ParentId, BillingStreet, BillingCity, BillingState,
BillingPostalCode, BillingCountry, BillingLatitude, BillingLongitude,
BillingGeocodeAccuracy, Phone, Fax, AccountNumber, Website, PhotoUrl,
@pchittum
pchittum / so-survey.txt
Last active August 29, 2015 14:19 — forked from tckmn/so-survey.txt
In what country do you currently reside?
United States
What city or town do you live in?
Houston
How old are you?
<20
What is your gender?
Male
Tabs or Spaces?
Spaces
@pchittum
pchittum / so-survey.txt
Last active August 29, 2015 14:19 — forked from tckmn/so-survey.txt
In what country do you currently reside?
United States
What city or town do you live in?
Houston
How old are you?
<20
What is your gender?
Male
Tabs or Spaces?
Spaces
@pchittum
pchittum / Component Controller
Last active August 29, 2015 14:16
Component Binding to Page
public class ComponentController {
public Id myId {get;set;}
public Expense__c exp {
get {
if (exp == null) {
exp = [select Id,Name,Amount__c from Expense__c where id =: myId];
}
return exp;
@pchittum
pchittum / Controller
Created February 9, 2015 11:43
Example code for force:input/outputField error
({
doInit: function(component, evt, helper) {
console.log('entered init');
var action = component.get("c.getAccount");
console.log('Apex METHOD:')
console.log(action);
action.setCallback(this, function(a) {
console.log('entered callback');