Skip to content

Instantly share code, notes, and snippets.

View pchittum's full-sized avatar

Peter Chittum pchittum

  • Freelance
  • UK
  • 07:04 (UTC -12:00)
View GitHub Profile
@pchittum
pchittum / PickListValues.cmp
Created September 18, 2017 23:21
PropertyDialog Stuff
<aura:component controller="PicklistController">
<aura:attribute name="sObjectName" type="String" />
<aura:attribute name="fieldName" type="String" />
<aura:attribute name="picklistValues" type="Object" />
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
</aura:component>
@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 / 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 / Merchandise Trigger
Last active December 31, 2015 14:49
INSSET Salesforce Programmer Training
trigger HandleProductPriceChange on Merchandise__c (after update) {
List<Line_Item__c> openLineItems =
[SELECT j.Unit_Price__c, j.Merchandise__r.Price__c
FROM Line_Item__c j
WHERE j.Invoice__r.Status__c = 'Negotiating'
AND j.Merchandise__r.id IN :Trigger.new
FOR UPDATE];
for (Line_Item__c li: openLineItems) {
@pchittum
pchittum / ViewStateStudy_controller
Created December 12, 2013 15:39
How Visualforce passes data between two pages. These are examples supporting a post on salesforce.stackexchange.com regarding how to "save" data when redirecting to another page. My argument was that one solution is to take advantage of view state in Visualforce to pass the data around. http://salesforce.stackexchange.com/questions/21899/starts-…
public with sharing class ViewStateStudy_controller {
public String accId{get;set;}
public Account account{get;set;}
public ViewStateStudy_controller()
{
accId = ApexPages.currentPage().getParameters().get('Id');
if(accId != null)
{
@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