Skip to content

Instantly share code, notes, and snippets.

<script type="text/javascript" runat="server">
// src: https://gist.github.com/wvpv/19777e1167d6ac91e2e8
Platform.Load("core", "1");
var debug = true;
var request = {};
SetVar("method", Request.Method)
@iamthefbi
iamthefbi / JWT.cls
Created December 9, 2019 13:34 — forked from douglascayers/JWT.cls
Sign a JWT token with only a private key
/**
* Inspired by the JWT repo by Salesforce Identity
* https://github.com/salesforceidentity/jwt/
*
* Inspired by the JWT repo by Auth0
* https://github.com/auth0/java-jwt
*
* Learn more about JWT at https://jwt.io
*/
public inherited sharing class JWT {
@iamthefbi
iamthefbi / ApprovalRequestComments.html
Created December 9, 2019 13:17 — forked from douglascayers/ApprovalRequestComments.html
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>
@iamthefbi
iamthefbi / tasks.json
Created December 5, 2019 09:24 — forked from douglascayers/tasks.json
Simple tasks for Visual Studio Code to deploy/retrieve/delete the currently opened file, or an entire folder, using Salesforce CLI force:source commands.
{
"version": "2.0.0",
"tasks": [
{
"label": "SFDX: Deploy Current File",
"type": "shell",
"command": "sfdx",
"args": [
"force:source:deploy",
"--sourcepath",
@iamthefbi
iamthefbi / gist:aaade5a64d6df0335f2c86cc1bf90126
Created November 25, 2019 15:54 — forked from dancinllama/gist:6581945
Using Kevin 080's trigger handler setup for kicking off batch jobs based on data load
protected override void afterInsert() {
boolean isSuccessfulRun = false;
for(Integer i=0; i < Trigger.new.size() && isSuccessful == false; i++){
isSuccessfulRun |= (((DL__c)Trigger.new.get(i)).Status__c == 'Completed');
}
if(isSuccessfulRun){
//Kick off batch jobs
Database.executeBatch(new MyNotSoFirstBatchJob(),50);
}
/**
* Sleep at least a second
*
* Found at: http://boards.developerforce.com/t5/Apex-Code-Development/Best-way-to-delay-until-time-changes-in-a-test/td-p/389619
*
*/
public static void waitAtLeastASecond() {
Integer msPerS = 1000;
Datetime start = Datetime.now();
Datetime current = Datetime.now();
if (
and (
YEAR(Date_Start__c) == YEAR(TODAY()),
IF(
CEILING( ( Date_Start__c - DATE( YEAR( Date_Start__c ), 1, 1) + 1) / 7) > 52,
52,
CEILING( ( Date_Start__c - DATE( YEAR( Date_Start__c ), 1, 1) + 1) / 7)
) ==
IF(
endpoint := instanceUrl + "/services/data/v39.0/tooling/query?q="
query := "SELECT ApexClassOrTriggerId, ApexClassorTrigger.Name, Coverage FROM ApexCodeCoverageAggregate"
http://forceastute.alexislam.com/2016/09/code-coverage-best-practices.html
@iamthefbi
iamthefbi / notes.txt
Last active April 23, 2019 16:40
SFDX and WSL setup notes
enable Windows Subsystem for Linux submodule then restart
install the following apps: wsltty
install inside wsl the following packages: fonts-powerline, bash-it
install the following node version manager: n
https://salesforce.stackexchange.com/questions/217035/auth-not-working-with-dx-and-windows-subsystem-for-linux-wsl/217104#217104
https://github.com/wadewegner/salesforce-cli-bash-completion
add firewall rule to enable npm to grab package (in Admin CMD prompt):
install windows version of sfdx
reload the wsl shell.
global class PrepareMySandbox implements SandboxPostCopy {
global void runApexClass(SandboxContext context) {
System.debug('Org ID: ' + context.organizationId());
System.debug('Sandbox ID: ' + context.sandboxId());
System.debug('Sandbox Name: ' + context.sandboxName());
// Insert logic here to prepare the sandbox for use.
}
}