Skip to content

Instantly share code, notes, and snippets.

Currently being awesome

Jeff Douglas jeffdonthemic

Currently being awesome
View GitHub Profile
jeffdonthemic / apex-crud-fls.txt
Last active Oct 9, 2019
Simple Apex Controller with CRUD and FLS
View apex-crud-fls.txt
This simple controller (without CRUD and FLS) ...
public with sharing class AccountController {
public static List<Account> findAll() {
return [SELECT id, name, Location__Latitude__s, Location__Longitude__s
FROM Account
WHERE Location__Latitude__s != NULL AND Location__Longitude__s != NULL
LIMIT 50];
jeffdonthemic / app.rb
Last active Sep 3, 2019
Refresh Token from Salesforce
View app.rb
require 'sinatra'
require 'omniauth'
require 'omniauth-salesforce'
rescue LoadError
require 'rubygems'
require 'sinatra'
require 'omniauth'
require 'omniauth-salesforce'
View Create Category Items
// create the association object with the final data
associations = {
"elements": elements
// create all of the associations
url: ''+process.env.CLOVER_MERCHANT_ID+'/category_items',
method: 'POST',
headers: {
jeffdonthemic / ChatterUtils
Last active Apr 1, 2019
Simple Class to add Salesforce Chatter posts with links, urls and mentions.
View ChatterUtils
public with sharing class ChatterUtils {
// makes a simple chatter text post to the specified user from the running user
public static void simpleTextPost(Id userId, String postText) {
ConnectApi.FeedType feedType = ConnectApi.FeedType.UserProfile;
ConnectApi.MessageBodyInput messageInput = new ConnectApi.MessageBodyInput();
messageInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();
View ContactListViewComponent.component
<apex:component controller="ContactListViewController">
<apex:attribute name="listViewName" type="String" required="true"
description="The name of the listview." assignTo="{!listName}"/>
<apex:enhancedList height="400" rowsPerPage="25" id="ContactList"
listId="{!listId}" rendered="{!listId != null}" />
<apex:outputText rendered="{!listId == null}" value="Could not find requewed ListView: '{!listName}'. Please contact your administrator."/>
jeffdonthemic / gist:e735a32350d8c54b27caf2d8ed95cd71
Created Jan 28, 2019
View gist:e735a32350d8c54b27caf2d8ed95cd71
Account a = new Account(name='Astro Chicken & Ribs Joint', BillingState='NY', ShippingState='NY', Type='Customer - Channel');
insert a;
Opportunity opp = new Opportunity(AccountId=a.Id,Name='Sell some chicken salad', StageName='Closed Won', Amount=99999,;
insert opp;
// ensure the flow ran successfully
System.assertEquals(1, [select count() from Robot_Setup__c where Opportunity__c = :opp.Id]);
// check the date
List<Robot_Setup__c> rs = [select id, date__c from Robot_Setup__c where Opportunity__c = :opp.Id limit 1];
System.assert([0].Date__c) >= 179);
// update so we can delete the opp
View app.js
function openModal(name) {
function closeModal(name) {
jeffdonthemic / AddToCart.evt
Last active Sep 28, 2018
Salesforce1 Lightning Demo for Spring '15
View AddToCart.evt
<aura:event type="APPLICATION" description="Add to cart event.">
<aura:attribute name="product" type="Product__c"/>
View app.js
var http = require('http');
var request = require('request');
var moment = require("moment");
var crypto = require('crypto');
var apiToken = 'MY-TOKEN';
var apiSecret = 'MY-SECRET';
var generateSession = function(userName, sessionName) {
var relativeUrl = "/services/api/sts/GenerateSession/"+userName+"/"+sessionName;
View Trailhead_User__c.object
<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="">