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 {
Provide a way to deserailize to a typed apex class, while also accessing any data for keys which were unmapped.
Apex
class Foo {
interface SObject{
id: string;
name: string;
// everything else optional
}
interface ServiceFactory<T extends SObject> {
// 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 |
{ | |
"version": "2.0.0", | |
"tasks": [ | |
{ | |
"label": "retrieve", | |
"type": "shell", | |
"command": "sfdx force:mdapi:retrieve -k deploy/package.xml -r deploy/", | |
"problemMatcher": [] | |
}, | |
{ |
{ | |
"packageDirectories": [ | |
{ | |
"path": "src", | |
"default": true | |
} | |
], | |
"namespace": "", | |
"sfdcLoginUrl": "https://login.salesforce.com", | |
"sourceApiVersion": "45.0" |
// 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 { |
<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}"> |
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.
Before starting, make sure you have the sfdx-cli install and a developer throw away org authenticated.
git clone https://github.com/ChuckJonas/ts-scratch-paper.git ts-force-tutorial
. cd into dirnpm install
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 |