Skip to content

Instantly share code, notes, and snippets.

View cdcarter's full-sized avatar

Christian Carter cdcarter

View GitHub Profile
@cdcarter
cdcarter / README.md
Last active August 25, 2017 19:44
NPSP Opportunity Action Rail

Place the NPSP Opportunity Action Rail right above the Opportunities related list on your Contact Lightning Page. The buttons will open up the Create Record modal for Opportunity with the Primary Contact & Account pre-populated. It uses the default record type, and your full page layouts (not a quick action!)

<project name="Sample usage of Salesforce Ant tasks" default="test" basedir="." xmlns:sf="antlib:com.salesforce">
<property file="build.properties"/>
<property environment="env"/>
<!-- Setting default value for username, password and session id properties to empty string
so unset values are treated as empty. Without this, ant expressions such as ${sf.username}
will be treated literally.
-->
<condition property="sf.username" value=""> <not> <isset property="sf.username"/> </not> </condition>
@cdcarter
cdcarter / apex_controller.java
Last active November 28, 2016 17:51
ValueSetProvider.cmp
public with sharing class LightningValueSetProvider {
@AuraEnabled
public static List<CustomValue> getValueSetForField(String sObjectName, String fieldName) {
List<CustomValue> options = new List<CustomValue>();
Schema.SObjectField field = Schema.getGlobalDescribe().get(sObjectName).getDescribe().fields.getMap().get(fieldName);
for (PicklistEntry value : field.getDescribe().getPicklistValues()) {
options.add(new CustomValue(value.getLabel(), value.getValue(), value.isDefaultValue()));
}
return options;
}
@cdcarter
cdcarter / ClientStoryHomePage.jsf
Last active July 16, 2016 20:34
Client Stories
<apex:page standardController="Contact" showHeader="false" sidebar="false" applyHtmlTag="false" standardStylesheets="false" docType="html-5.0">
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous"/>
<title>Wayfinder Story Submission</title>
</head>
global class Summer16EmailAction {
@invocableMethod
global static void renderEmailToChatter(List<EmailRequest> emails) {
List<ConnectApi.BatchInput> batchInputs = new List<ConnectApi.BatchInput>();
for(EmailRequest email : emails) {
ConnectApi.FeedItemInput input = new ConnectApi.FeedItemInput();
input.subjectId = email.getFeedId();
ConnectApi.MessageBodyInput body = new ConnectApi.MessageBodyInput();
body.messageSegments = new List<ConnectApi.MessageSegmentInput>();
ConnectApi.TextSegmentInput textSegment = new ConnectApi.TextSegmentInput();
module SObject exposing (Model, Msg, helpLoad, init, update, view)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
import Html.App
import Http
import Json.Decode as Json
import Task
import Field
@cdcarter
cdcarter / QuickData.java
Last active May 29, 2016 04:31
QuickData
public class QuickData {
/* QuickData inserts your Mockaroo Schema, no questions asked. Remote Site needed.
* USAGE: QuickData.createRecords('MOCKAROOAPIKEY','20689c00',20,List<Lead>.class);
* Creates 20 leads using the schema at https://www.mockaroo.com/20689c00 */
public static List<SObject> createRecords(String a, String s, Integer c, Type t) {
String fmtStr = 'https://www.mockaroo.com/{1}/download?count={2}&key={0}';
List<String> reqDetails = new List<String>{a,s,String.valueOf(c)};
string requestString = String.format(fmtStr,reqDetails);
HttpRequest req = new HttpRequest();
req.setEndpoint(requestString);
@cdcarter
cdcarter / debug.jsp
Last active May 7, 2016 23:16
Visualforce Debug Pane
<!-- the devconsole parameter is automatically set when a page is in refresh/preview mode from Developer Console
which allows us to only display our custom viewstate debug pane when we're in Developer Mode! -->
<apex:pageBlockSection id="debug" title="Debugging" rendered="{!$CurrentPage.parameters.core.apexpages.request.devconsole == '1'}">
<apex:pageBlockTable value="{!clients}" var="client">
<apex:column value="{!client.Name}"/>
<apex:column value="{!client.Enrollment_Status__c}"/>
<apex:column value="{!client.Referral_Agency__c}"/>
<apex:column >
<apex:facet name="header">Saved</apex:facet>
<apex:outputPanel rendered="{!NOT(ISBLANK(client.Id))}" layout="block"><input disabled="true" type="checkbox" checked="true"/></apex:outputPanel>
@cdcarter
cdcarter / superbatch.java
Last active March 12, 2016 21:39
SuperBatch
// a batch class for every context, by @cdcarter
public class SuperBatch implements Database.Batchable<SObject>, Schedulable {
// from anon apex, `SuperBatch.startBatch()` starts the job with batch size 100
public static void startBatch() { (new SuperBatch()).doIt(); }
public SuperBatch() {}
public void doIt() { Database.executeBatch(this,100); }
/* create a visualforce page below, and a list button
* add the list button to list views to ondemand run the batch (size 100)
* <apex:page standardController="SObject" recordSetVar="sobj"
@cdcarter
cdcarter / deactivateTrigger.apxc
Created February 27, 2016 22:45
deactivate-relationship-trigger
npsp__Trigger_Handler__c th = [SELECT Id FROM npsp__Trigger_Handler__c WHERE npsp__Class__c = 'REL_Relationships_TDTM' LIMIT 1];
th.npsp__Active__c = false;
update th;