Skip to content

Instantly share code, notes, and snippets.

Avatar

Jason Hoult JasonHoult1981

View GitHub Profile
@douglascayers
douglascayers / InvocableApexTemplate.cls
Created Jan 4, 2018
Example structure of an invocable apex class
View InvocableApexTemplate.cls
public with sharing class InvocableApexTemplate {
@InvocableMethod(
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
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
douglascayers / SendEmailBatchable.java
Created Jan 4, 2017
Example Apex classes to enable Process Builder to send emails without using Email Alerts + Templates or launching a Flow.
View SendEmailBatchable.java
/**
* Developed by Doug Ayers
* douglascayers.com
*
* 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.
* https://developer.salesforce.com/docs/atlas.en-us.salesforce_app_limits_cheatsheet.meta/salesforce_app_limits_cheatsheet/salesforce_app_limits_platform_apexgov.htm
*
@emoran
emoran / PDF_Table.page
Created Sep 25, 2015
Visualforce page with styled html table.
View PDF_Table.page
<apex:page standardController="Account" standardStylesheets="false" applyHtmlTag="false" showHeader="false" renderAs="PDF">
<head>
<style type="text/CSS">
body{
font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;
}
.center{
text-align:center;
@douglascayers
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 (douglascayers.com)
*/
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
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>();