Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Currently being awesome

Jeff Douglas jeffdonthemic

💭
Currently being awesome
View GitHub Profile
@jeffdonthemic
jeffdonthemic / app.rb
Last active Sep 3, 2019
Refresh Token from Salesforce
View app.rb
begin
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
request({
url: 'https://api.clover.com:443/v3/merchants/'+process.env.CLOVER_MERCHANT_ID+'/category_items',
method: 'POST',
headers: {
@jeffdonthemic
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."/>
</apex:component>
@jeffdonthemic
jeffdonthemic / gist:e735a32350d8c54b27caf2d8ed95cd71
Created Jan 28, 2019
superbadge_process_automation_opportunity_automation
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, CloseDate=Date.today());
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(Date.today().daysBetween(rs[0].Date__c) >= 179);
// update so we can delete the opp
@jeffdonthemic
jeffdonthemic / CustomAccountLookup.page
Last active Jan 24, 2019
Roll Your Own Salesforce "Lookup" Popup Window blog post
View CustomAccountLookup.page
<apex:page controller="CustomAccountLookupController"
title="Search"
showHeader="false"
sideBar="false"
tabStyle="Account"
id="pg">
<apex:form >
<apex:outputPanel id="page" layout="block" style="margin:5px;padding:10px;padding-top:2px;">
<apex:tabPanel switchType="client" selectedTab="name1" id="tabbedPanel">
View app.js
function openModal(name) {
$("#"+name).addClass('slds-fade-in-open');
$("#backdrop").addClass('slds-backdrop_open');
}
function closeModal(name) {
$("#"+name).removeClass('slds-fade-in-open');
$("#backdrop").removeClass('slds-backdrop_open');
}
@jeffdonthemic
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"/>
</aura:event>
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="http://soap.sforce.com/2006/04/metadata">
<actionOverrides>
<actionName>Accept</actionName>
<type>Default</type>
</actionOverrides>
<actionOverrides>
<actionName>CancelEdit</actionName>
<type>Default</type>
</actionOverrides>
You can’t perform that action at this time.