Skip to content

Instantly share code, notes, and snippets.

View JasonHoult1981's full-sized avatar

Jason Hoult JasonHoult1981

View GitHub Profile
@jeffdonthemic
jeffdonthemic / ChatterUtils
Last active April 1, 2019 00:21
Simple Class to add Salesforce Chatter posts with links, urls and mentions.
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>();
@douglascayers
douglascayers / DuplicateRecordUtils.c
Last active March 16, 2022 06:35
Devising way to use Salesforce process builder and flow to automate merging duplicate records
/**
* 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'.
@emoran
emoran / PDF_Table.page
Created September 25, 2015 15:00
Visualforce page with styled html table.
<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 / SendEmailBatchable.java
Created January 4, 2017 05:32
Example Apex classes to enable Process Builder to send emails without using Email Alerts + Templates or launching a Flow.
/**
* 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
*
@douglascayers
douglascayers / CaseOpenBizHoursBatchable.cls
Last active April 1, 2019 00:14
Simple batchable to compute the number of hours a case was open, taking into consideration BusinessHours. Can be scheduled to run hourly.
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 / InvocableApexTemplate.cls
Created January 4, 2018 08:15
Example structure of an invocable apex class
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>();