Skip to content

Instantly share code, notes, and snippets.

Andrew Fawcett afawcett

Block or report user

Report or block afawcett

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@afawcett
afawcett / CMTService.cls
Last active Aug 17, 2018 — forked from madmax983/CMTService.cls
Apex Stub API with Static Methods
View CMTService.cls
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);
cmtWrappers.add(cmtWrapper);
}
return cmtWrappers;
@afawcett
afawcett / README.md
Last active Nov 25, 2018
Apex MD API and XSLT
View README.md

Requirement

Perform XSLT transform on XML returned from the Salesforce Metadata API retrieve operation (also requires unzip). Based on the code in https://github.com/financialforcedev/apex-mdapi

Solution

Adapting the metadataretrieve.page 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
afawcett / EinsteinSentimentAction.cls
Created Jul 31, 2017
Einstein Sentiment Wrappers
View EinsteinSentimentAction.cls
public with sharing class EinsteinSentimentAction {
public class Request {
@InvocableVariable
public String recordId;
@InvocableVariable
public String document;
@InvocableVariable
public String modelId;
}
@afawcett
afawcett / WidgetRecordEdit.cmp
Created May 30, 2017
Lightning Component for Lightning Edit Action Override
View WidgetRecordEdit.cmp
<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" />
<force:recordData
aura:id="recordLoader"
recordId="{!v.recordId}"
layoutType="FULL"
View CustomMetadata.cls
/**
*
CustomMetadata.Operations
.callback(
// Platform event for deploy status
MetadataDeployment__e.getSObjectType(),
MetadataDeployment__e.DeploymentId__c,
MetadataDeployment__e.Result__c)
.enqueueUpsertRecords(
// Metadata record type
View EinsteinAction.cls
public with sharing class EinsteinAction {
public class Prediction {
@InvocableVariable
public String label;
@InvocableVariable
public Double probability;
}
@InvocableMethod(label='Classify the given files' description='Calls the Einsten API to classify the given ContentVersion files.')
@afawcett
afawcett / MyReportNotificationFlow-1.flow
Created Sep 26, 2016
Definition of the TaskReminder Flow
View MyReportNotificationFlow-1.flow
<?xml version="1.0" encoding="UTF-8"?>
<Flow xmlns="http://soap.sforce.com/2006/04/metadata">
<actionCalls>
<name>TaskReminder</name>
<label>TaskReminder</label>
<locationX>21</locationX>
<locationY>32</locationY>
<actionName>NewTask</actionName>
<actionType>quickAction</actionType>
<inputParameters>
@afawcett
afawcett / build.xml
Created Jul 16, 2016
Cloud9 /src Directory Fix
View build.xml
<project>
<target name="cloud9.github.init">
</target>
<target name="sync.from.cloud9">
<sync todir="src/classes" verbose="true">
<fileset dir="${basedir}/classes">
<exclude name="**/.c9/**"/>
</fileset>
</sync>
View PermissionSetTestExample.cls
PermissionSet permissionSet = new PermissionSet();
permissionSet.Name='ApexTest';
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
afawcett / AddressFinder.cmp
Last active Apr 26, 2018
Salesforce London World Tour 2016: Lightning Out: Components on Any Platform
View AddressFinder.cmp
<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>
You can’t perform that action at this time.