Skip to content

Instantly share code, notes, and snippets.

View johndstein's full-sized avatar

John Stein johndstein

View GitHub Profile
@johndstein
johndstein / equalIn.java
Last active August 29, 2017 13:46
APEX SOQL equal and in both work
// Maybe everyone already knew this, but equal and in both work for collections
// in APEX.
Account_Team__c[] ats = [select Id, Account__c from Account_Team__c limit 3];
Set<Id> accId = new Set<Id>();
for (Account_Team__c at : ats) {
accId.add(at.Account__c);
}
Account_Team__c[] accTeams = [
SELECT Account__c, Role__c, User__c
FROM Account_Team__c
@johndstein
johndstein / anomaly.java
Last active August 26, 2017 19:21
Salesforce Date and Datetime anomaly
// If you create a Datetime instance from a date and then create a Date
// instance from the year, month and day of the datetime, you probably
// won't get the date instance you expect.
Datetime dt = Datetime.newInstance(2017,12,31);
System.debug('dt: ' + Date.newInstance(dt.year(),dt.month(),dt.day()));
Datetime fromdt = Date.valueOf('2017-12-31');
System.debug('date: ' + Date.valueOf('2017-12-31'));
System.debug('fromdt: ' + fromdt);
System.debug('fromdt Date: ' + Date.newInstance(fromdt.year(),fromdt.month(),fromdt.day()));
@johndstein
johndstein / recurring.sql
Created August 17, 2017 20:59
recurring.sql
-- NOTE Bank is only tied to the original gift, not the adjustment.
-- NOTE Bank account number and routing number comes from re_reporter..re_eft
-- which is a file that betsy had someone create. we will need it in prod.
-- NOTE We have found Annually, Semi-anually, Quarterly, Monthly and
-- Bi-monthly schedules in the staging database.
-- We can't handle Bi-monthly (twice a month).
-- So we create two different monthly records.
-- NOTE We can't handle anything if it's other than installment_frequency
-- 1 through 6. If there are it will display ERROR in the
-- ChargentOrders__Payment_Frequency__c and error on insert into SF.
[Encoding]
InputEncoding=UTF8
[WFClient]
CPMAllowed=On
ClientName=WI_cjt98gmnZcJKYtLo0
HotKey11Shift=(none)
HotKey12Shift=(none)
HotKey13Shift=(none)
HotKey9Shift=(none)
[user]
name = John Stein
email = john@johnandkerri.com
[color]
diff = auto
status = auto
branch = auto
interactive = auto
[alias]
st = status
Johns-MacBook-Pro:~ johnstein$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
==> The following existing directories will be made group writable:
/usr/local/bin
@johndstein
johndstein / missing_bank_info.sql
Last active March 29, 2017 20:52
Query to check for missing bank account info
select
g.id RE_LEGACY_ID__c,
r.constituent_id,
ree.routingno ChargentOrders__Bank_Routing_Number__c,
ree.accountnumber ChargentOrders__Bank_Account_Number__c,
coalesce(sfc.AccountId, sfa.Id) ChargentOrders__Account__c,
g.constituentbankid RE_BANK_ID__c,
case (select accounttype from constituent_bank where id = g.constituentbankid)
when 0 then 'Checking'
when 1 then 'Savings'
@johndstein
johndstein / re-attributes.sql
Created February 9, 2017 20:25
Raiser's Edge Gift Attributes
-- Shows some helpful info about gift attributes.
-- This SQL is for SQL Server.
DECLARE @attr varchar(MAX)
SET @attr = 'Legacy Correction'
-- Overall Count
select count(*) count
from giftattributes ga
join attributetypes at on ga.attributetypesid = at.attributetypesid
public with sharing class MembershipMigrator {
//public MembershipMigrator() {
//}
// 1968 total
public List<Account> listMemberAccounts() {
return [
select Id,
@johndstein
johndstein / states.json
Created November 16, 2016 19:25
Salesforce US United States List JSON
{
"AE": "Armed Forces Europe",
"AK": "Alaska",
"AL": "Alabama",
"AP": "Armed Forces Pacific",
"AR": "Arkansas",
"AS": "American Samoa",
"AZ": "Arizona",
"CA": "California",
"CO": "Colorado",