Skip to content

Instantly share code, notes, and snippets.


Jason Hoult JasonHoult1981

View GitHub Profile
douglascayers / InvocableApexTemplate.cls
Created Jan 4, 2018
Example structure of an invocable apex class
View InvocableApexTemplate.cls
public with sharing class InvocableApexTemplate {
label = 'Name as displayed in Process Builder'
description = 'Tooltip as displayed in Process Builder'
public static List<Response> execute( List<Request> requests ) {
List<Response> responses = new List<Response>();
douglascayers / CaseOpenBizHoursBatchable.cls
Last active Apr 1, 2019
Simple batchable to compute the number of hours a case was open, taking into consideration BusinessHours. Can be scheduled to run hourly.
View CaseOpenBizHoursBatchable.cls
public class CaseOpenBizHoursBatchable implements Database.Batchable<SObject>, Database.Stateful {
private ID businessHoursId { get; set; }
public CaseOpenBizHoursBatchable( ID businessHoursId ) {
this.businessHoursId = businessHoursId;
public Database.QueryLocator start( Database.BatchableContext context ) {
// Idea behind this query is to get all open cases or
douglascayers /
Created Jan 4, 2017
Example Apex classes to enable Process Builder to send emails without using Email Alerts + Templates or launching a Flow.
* Developed by Doug Ayers
* Designed to be used by SendEmailInvocable class when sending
* several emails but need to stay within the apex governor limits
* of how many emails can be sent per transaction. Call this batchable
* with all the emails to send and set the batch size to max per transaction.
emoran /
Created Sep 25, 2015
Visualforce page with styled html table.
<apex:page standardController="Account" standardStylesheets="false" applyHtmlTag="false" showHeader="false" renderAs="PDF">
<style type="text/CSS">
font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;
douglascayers / DuplicateRecordUtils.c
Last active Mar 16, 2022
Devising way to use Salesforce process builder and flow to automate merging duplicate records
View DuplicateRecordUtils.c
* Developed by Doug Ayers (
public with sharing class DuplicateRecordUtils {
public static Set<ID> getDuplicateRecordIds( ID recordId ) {
Set<ID> duplicateRecordIds = new Set<ID>();
// Potential duplicate records are grouped together into 'duplicate record sets'.
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>();