Skip to content

Instantly share code, notes, and snippets.

View afawcett's full-sized avatar

Andrew Fawcett afawcett

View GitHub Profile
@afawcett
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);
cmtWrappers.add(cmtWrapper);
}
return cmtWrappers;
@afawcett
afawcett / README.md
Last active November 25, 2018 10:10
Apex MD API and XSLT

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 July 31, 2017 01:45
Einstein Sentiment Wrappers
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 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" />
<force:recordData
aura:id="recordLoader"
recordId="{!v.recordId}"
layoutType="FULL"
/**
*
CustomMetadata.Operations
.callback(
// Platform event for deploy status
MetadataDeployment__e.getSObjectType(),
MetadataDeployment__e.DeploymentId__c,
MetadataDeployment__e.Result__c)
.enqueueUpsertRecords(
// Metadata record type
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 September 26, 2016 09:25
Definition of the TaskReminder 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 July 16, 2016 11:15
Cloud9 /src Directory Fix
<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>
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 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>