Skip to content

Instantly share code, notes, and snippets.

View ChuckJonas's full-sized avatar

Charlie Jonas ChuckJonas

  • Callaway Cloud Consulting
  • wyoming
View GitHub Profile
<apex:page tabStyle="Lead" standardController="Lead" extensions="LeadCloneWithActivitiesController" >
<apex:form >
<apex:sectionHeader title="Cloning" subtitle="{!Lead.Name} and Activities ({!clone.Tasks.size + clone.Events.size})" />
<apex:pageBlock title="Lead Clone" tabStyle="Lead" >
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton value="Cancel" action="{!cancel}" />
<apex:commandButton value="Save" action="{!saveClone}" />
</apex:pageBlockButtons>
<apex:outputPanel rendered="{!leadLayout!=null && clone != null}">
@ChuckJonas
ChuckJonas / LeadCloneWithActivitiesController.apex.java
Last active November 17, 2018 19:04
LeadCloneWithActivitesController
// Author Charlie@callaway.cloud
// Replacement clone page which copies activity history
public with sharing class LeadCloneWithActivitiesController {
private SObjectDeepClone cloner; //cloning util
public Lead clone {get; private set;} //editable lead
public Metadata.Layout leadLayout {get; private set;} //layout
public Metadata.UiBehavior editEnum {
@ChuckJonas
ChuckJonas / tutorial.md
Last active October 27, 2018 04:27
ts-force tutorial

ts-force tutorial

This tutorial will walk will cover the basics of using ts-force. While quite a bit of functionality is not covered, I've tried to include the most common use cases.

install & configuration

Before starting, make sure you have the sfdx-cli install and a developer throw away org authenticated.

  1. git clone https://github.com/ChuckJonas/ts-scratch-paper.git ts-force-tutorial. cd into dir
  2. npm install
  3. npm install ts-force -S
(function() {
const {$A} = window;
return {
"meta":{
"name":"c$BeerList",
"extends":"markup://aura:component"
},
"controller":{
"locationChange":function(component, event, helper) {
({
minAlcohol: 0,
getBeers: function (component, page) {
var searchKey = window.location.hash.substr(1);
page = page || 1;
var action = component.get("c.findAll");
action.setParams({
"searchKey": searchKey,
"minAlcohol": this.minAlcohol,
"pageNumber": page
@ChuckJonas
ChuckJonas / bm.ts
Created June 30, 2018 18:15
week2-bm
declare function require(name:string);
const { performance } = require('perf_hooks');
export class Timer{
private _start: number;
public start(){
this._start = performance.now();
}
//returns time in ms
@ChuckJonas
ChuckJonas / fail.cls
Last active June 21, 2018 08:13
Apex (Salesforce) switch statement
//...
private static final String TARGET_VALUE = 'new'; //compile time constant
//...
Account acc = new Account(name= TARGET_VALUE);
switch on acc.Name {
when TARGET_VALUE { //ERROR: when identifier' is only allowed for switch on enum
}
}
@ChuckJonas
ChuckJonas / Solution
Created June 14, 2018 01:39
Functional Method Array Challenge
//=== CHALLENGE #1 ===
type Data1Type = {
name: string,
timeEntries: { credit: boolean, hours: number }[],
role: string
}
type Solution1Type = { name: string, totalHours: number }
@ChuckJonas
ChuckJonas / ts-force-config.json
Last active April 20, 2018 03:48
BASS ts-force example
{
"auth": {
"username": "my-dev"
},
"sObjects": [
"Account",
"User",
{
"apiName": "Contact",
"fieldMappings": [
@ChuckJonas
ChuckJonas / ts-force-example.ts
Last active April 7, 2018 04:45
BASS ts-force example
let accId = 'blah';
let accounts = await Account.retrieve(
`SELECT ${generateSelect(Object.values(Account.FIELDS))},
(
SELECT Owner.Id, Owner.Name
FROM ${Account.FIELDS.contacts.apiName}
)
FROM Account
WHERE Id = '${accId}'`
);