Skip to content

Instantly share code, notes, and snippets.

Avatar

Charlie Jonas ChuckJonas

  • Callaway Cloud Consulting
  • Jackson Wy
View GitHub Profile
View json-unmapped-props.md

Goal

Provide a way to deserailize to a typed apex class, while also accessing any data for keys which were unmapped.

Example:

Apex

class Foo {
@ChuckJonas
ChuckJonas / Stubbing.md
Last active Feb 13, 2020
ts-force redesign
View Stubbing.md

interfaces

interface SObject{
  id: string;
  name: string;
  // everything else optional
}

interface ServiceFactory<T extends SObject> {
View AccountInsertInvokable.java
// Modeled after example found here: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_InvocableMethod.htm
// Expanded to show how an interface might help overcome some of the limits around existing @Invokable implementation
public class AccountInsertInvokable implements Invokable<Account, Id> {
private Boolean allOrNone;
private Boolean logFailures;
// @InvokableSetup this as a configuration point for ProcessBuilder/Flow
// Params Restricted to same types as @InvocableVariable
@InvokableSetup
@ChuckJonas
ChuckJonas / tasks.json
Last active Jul 11, 2019
salesforce vscode setup
View tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "retrieve",
"type": "shell",
"command": "sfdx force:mdapi:retrieve -k deploy/package.xml -r deploy/",
"problemMatcher": []
},
{
@ChuckJonas
ChuckJonas / sfdx-project.json
Last active Jun 28, 2019
Mavensmate -> salesforce-vscode Transition Files
View sfdx-project.json
{
"packageDirectories": [
{
"path": "src",
"default": true
}
],
"namespace": "",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "45.0"
View LeadCloneWithActivitiesController.apex.java
// 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 {
View LeadCloneWithActivities.page.xhtml
<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 / tutorial.md
Last active Oct 27, 2018
ts-force tutorial
View tutorial.md

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
View beerList.js
(function() {
const {$A} = window;
return {
"meta":{
"name":"c$BeerList",
"extends":"markup://aura:component"
},
"controller":{
"locationChange":function(component, event, helper) {
View beerListHelper.js
({
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