Skip to content

Instantly share code, notes, and snippets.

View afawcett's full-sized avatar

Andrew Fawcett afawcett

View GitHub Profile
afawcett / CMTService.cls
Last active August 17, 2018 23:53 — forked from madmax983/CMTService.cls
Apex Stub API with Static Methods
public with sharing class CMTService {
public List<CMTWrapper> getCMTs() {
List<CMTWrapper> cmtWrappers = new List<CMTWrapper>();
List<CMT__mdt> cmts = [SELECT Example_Field_1__c, Example_Field_2_c FROM CMT__mdt];
for(CMT__mdt c : cmts) {
CMTWrapper cmtWrapper = new CMTWrapper(c.Example_Field_1__c, c.Example_Field_2__c);
return cmtWrappers;
afawcett /
Last active November 25, 2018 10:10
Apex MD API and XSLT


Perform XSLT transform on XML returned from the Salesforce Metadata API retrieve operation (also requires unzip). Based on the code in


Adapting the in the above repository. The original page passed the client side unzipped files from the MD retrieve zip file back to the server to add to the view state for display. As the XSLT is done client side, the above page is much simpler, the unzipped files are just handled client side and added dynamically to the page DOM.

Implementaiton Notes

  • XSLT is loaded from a static resource
afawcett / EinsteinSentimentAction.cls
Created July 31, 2017 01:45
Einstein Sentiment Wrappers
public with sharing class EinsteinSentimentAction {
public class Request {
public String recordId;
public String document;
public String modelId;
afawcett / WidgetRecordEdit.cmp
Created May 30, 2017 02:15
Lightning Component for Lightning Edit Action Override
<aura:component implements="lightning:actionOverride,force:hasRecordId,force:hasSObjectName">
<aura:attribute name="record" type="Object" />
<aura:attribute name="componentRecord" type="Object" />
<aura:attribute name="recordError" type="String" />
// Platform event for deploy status
// Metadata record type
public with sharing class EinsteinAction {
public class Prediction {
public String label;
public Double probability;
@InvocableMethod(label='Classify the given files' description='Calls the Einsten API to classify the given ContentVersion files.')
afawcett / MyReportNotificationFlow-1.flow
Created September 26, 2016 09:25
Definition of the TaskReminder Flow
<?xml version="1.0" encoding="UTF-8"?>
<Flow xmlns="">
afawcett / build.xml
Created July 16, 2016 11:15
Cloud9 /src Directory Fix
<target name="cloud9.github.init">
<target name="sync.from.cloud9">
<sync todir="src/classes" verbose="true">
<fileset dir="${basedir}/classes">
<exclude name="**/.c9/**"/>
PermissionSet permissionSet = new PermissionSet();
permissionSet.label='Apex Test';
insert permissionSet;
ObjectPermissions objectPermission = new ObjectPermissions();
objectPermission.ParentId = permissionSet.Id;
objectPermission.SObjectType = Book_Order__c.SObjectType.getDescribe().getName();
objectPermission.PermissionsEdit = true;
objectPermission.PermissionsRead = true;
objectPermission.PermissionsDelete = true;
afawcett / AddressFinder.cmp
Last active November 25, 2022 08:58
Salesforce London World Tour 2016: Lightning Out: Components on Any Platform
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes"
controller="AddressFinderController" access="global">
<aura:attribute name="accounts" type="Account[]"/>
<aura:attribute name="contacts" type="Contact[]"/>
<aura:registerEvent name="AddressInfo" type="c:AddressInfo"/>
<div class="slds-form--stacked">
<div class="slds-form-element">
<label class="slds-form-element__label" for="inputSample2">Account Search</label>