Skip to content

Instantly share code, notes, and snippets.

View douglascayers's full-sized avatar

Doug Ayers douglascayers

View GitHub Profile
<project name="gradle-ant" default="" basedir=".">
<!--
Inspired by Ray Myers
https://gist.github.com/raymyers/735788
-->
<property environment="env" />
<condition property="gradle.home.executable" value="${env.GRADLE_HOME}/bin/gradle.bat" else="${env.GRADLE_HOME}/bin/gradle">
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 / vCalendarPage.html
Last active July 13, 2023 21:59
Create .ics Calendar Event in Visualforce
<!--
Simple proof-of-concept to create a .ics calendar event with visualforce.
Inspired by Natalie Regier @gnatrae
This example uses url parameters to set the details of event.
You could create a custom button that invokes this page, like:
https://<your-salesforce-domain>/apex/vCalendarPage?start={!TEXT(Obj.StartDate__c)}&end={!TEXT(Obj.EndDate__c)}&subject=Event from Visualforce&description=This .ics event created with visualforce&location=The Cloud
An example with literal values you can copy & paste in your browser:
https://<your-salesforce-domain>/apex/vCalendarPage?start=20140524T140000&end=20140524T153000&subject=Event from Visualforce&description=This .ics event created with visualforce&location=The Cloud
<?xml version="1.0"?>
<project name="Demo" default="version" basedir=".">
<macrodef name="git">
<attribute name="command" />
<attribute name="dir" default="" />
<element name="args" optional="true" />
<sequential>
<echo message="git @{command}" />
<exec executable="git" dir="@{dir}">
@douglascayers
douglascayers / ApprovalRequestComments.html
Last active October 20, 2023 05:09
Approval Request Comments in Visualforce Email Template.
<apex:component controller="ApprovalRequestCommentsController" access="global">
<apex:attribute name="relatedToId" assignTo="{!targetObjectId}" type="String" description="ID of the record whose last approval comments to retrieve"/>
<apex:outputText value="{!comments}"/>
</apex:component>
@douglascayers
douglascayers / BMCRF_IncidentTrigger.cls
Last active August 29, 2015 14:12
Apex code examples for blog post
/**
* Written by Doug Ayers, https://communities.bmc.com/people/douglas.ayers%40fotlinc.com
* Inspired by Paul Donders, https://communities.bmc.com/people/p.donders@infravision.com
* BMC Communities, https://communities.bmc.com/ideas/3039
*/
trigger BMCRF_IncidentTrigger on BMCServiceDesk__Incident__c ( before update ) {
if ( Trigger.isBefore && Trigger.isUpdate ) {
BMCRF_IncidentTriggerHelper.checkAndSetImpact( Trigger.new );
BMCRF_IncidentTriggerHelper.checkAndSetUrgency( Trigger.new );
@douglascayers
douglascayers / QueueMembersController.cls
Last active February 20, 2017 16:09
Sample code for blog post on exporting Queue members as Excel
public class QueueMembersController {
// selected queue whose members to view
public ID queueId { get; set; }
// provide queue name to show on page
public Group selectedQueue {
get {
return [
SELECT
@douglascayers
douglascayers / build.properties
Created January 7, 2015 09:09
Force.com Migration Tool
#
# Specify System Administrator credentials
# that will login to Salesforce to retrieve the metadata.
#
# You will also need the security token.
#
# The server url is which instance to connect to:
# For sandboxes, use https://test.salesforce.com
# For production or developer orgs, use https://login.salesforce.com
#
@douglascayers
douglascayers / Calendar Attachment Email Template.html
Last active April 18, 2023 20:22
Example Visualforce Template with iCal Attachment
<messaging:emailTemplate subject="Close Opportunity"
recipientType="User"
relatedToType="Opportunity">
<messaging:htmlEmailBody >
<html>
<body>
Opportunity: <a href="https://test.salesforce.com/{!relatedTo.id}"><apex:outputText value="{!relatedTo.name}"/></a>
<br/>
@douglascayers
douglascayers / GoogleAnalytics.js
Created March 24, 2015 14:47
Google Analytics for Salesforce
// hide sidebar component that embedded this javascript
$("h2:contains('Google Analytics')").parent().parent().hide();
// Google Universal Analytics (provided by google)
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
// Our analytics tracking id for salesforce production.