Skip to content

Instantly share code, notes, and snippets.

👨‍💻
Coding

Doug Ayers douglascayers

View GitHub Profile
@douglascayers
douglascayers / sfdx-project.json
Last active Feb 17, 2019
Simple Salesforce DX project configuration file to activate Salesforce Extensions for Visual Studio Code.
View sfdx-project.json
{
"packageDirectories": [
{
"path": "force-app",
"default": true
}
],
"namespace": "",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "45.0"
@douglascayers
douglascayers / tasks.json
Last active Apr 5, 2019
Simple tasks for Visual Studio Code to deploy/retrieve/delete the currently opened file, or an entire folder, using Salesforce CLI force:source commands.
View tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "SFDX: Deploy Current File",
"type": "shell",
"command": "sfdx",
"args": [
"force:source:deploy",
"--sourcepath",
@douglascayers
douglascayers / setup.sh
Created Feb 5, 2019
Deploy Chatter Bot for Feeds using Salesforce CLI
View setup.sh
# Install Git
# https://git-scm.com/downloads
# Install Salesforce CLI
# https://developer.salesforce.com/tools/sfdxcli
# Authorize to the org you want to install Chatter Bot apps to
sfdx force:auth:web:login -a YourOrgAlias
# Download the Chatter Bot Groups app and deploy to your org (pre-requisite for Chatter Bot Feeds demo)
View sfdx-mass-action-scheduler-version.js
{
"version": "2.1",
"url": "https://douglascayers.github.io/sfdx-mass-action-scheduler/#packaged-release-history"
}
View SharedLibrary.js
/* SharedLibrary.js, upload as a static resource */
window.sum = function(a, b) {
return ( a + b );
}
View ServiceComponent.html
<!-- ServiceComponent.cmp -->
<aura:component>
<aura:method name="sum" action="{!c.handleSum}">
<aura:attribute name="a" type="Integer" required="true"/>
<aura:attribute name="b" type="Integer" required="true"/>
</aura:method>
</aura:component>
View controller.js
/* controller.js */
({
onActionConfirmed: function(component, event, helper) {
helper.callServer();
})
@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 / GoogleDocToFilesBatchable.cls
Last active Nov 8, 2018
Example code to convert GoogleDoc into ContentVersion (external file reference)
View GoogleDocToFilesBatchable.cls
public class GoogleDocToFilesBatchable implements Database.Batchable<SObject>, Database.Stateful {
private ID externalDataSourceId { get; set; }
public GoogleDocToFilesBatchable( ID externalDataSourceId ) {
this.externalDataSourceId = externalDataSourceId;
}
public Database.QueryLocator start( Database.BatchableContext context ) {
return Database.getQueryLocator([
You can’t perform that action at this time.