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 / Mock.cls
Last active Aug 29, 2019
Mocking SOQL result set containing sub-selects
View Mock.cls
/**
* Copyright (c), Andrew Fawcett
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
@afawcett
afawcett / BatchWorker.cls
Last active Apr 30, 2019
Sample code from
View BatchWorker.cls
/**
* Copyright (c) 2013, Andrew Fawcett
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
@afawcett
afawcett / CustomPermissionsReader.cls
Last active Apr 11, 2019
CustomPermissionsReader
View CustomPermissionsReader.cls
/**
* Copyright (c), Andrew Fawcett
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
@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"
@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 / ant-salesforce.xml
Last active Nov 25, 2018
Defines some macros around sf:deploy to install and uninstall packages.
View ant-salesforce.xml
<!-- TODO: Review Ant v1.8 local properties -->
<project xmlns:sf="antlib:com.salesforce">
<!-- Download from Salesforce Tools page under Setup -->
<typedef
uri="antlib:com.salesforce"
resource="com/salesforce/antlib.xml"
classpath="${basedir}/lib/ant-salesforce.jar"/>
<!-- Download from http://sourceforge.net/projects/ant-contrib/files/ant-contrib/1.0b3/ -->
@afawcett
afawcett / Address.cls
Last active Oct 15, 2018
Apex Address compound type, based on that provided in Spring'14 for Salesforce API, http://www.salesforce.com/us/developer/docs/api/Content/compound_fields_address.htm
View Address.cls
public class Address
{
// Internally used to determine if valueOf method should read the state and country picker fields
private static Boolean stateAndCountryPickersEnabled = false;
static
{
// Are State and Country pickers enabled in this org?
Map<String, Schema.SObjectField> accountFields = Account.sObjectType.getDescribe().fields.getMap();
stateAndCountryPickersEnabled = accountFields.containsKey('BillingStateCode');
@afawcett
afawcett / AddPicklistItemAction.cls
Last active Sep 16, 2018
Prototype Invocable Method wrapping the Salesforce Metadata API to allow management of Picklist Items via Process Builder and Visual Flow
View AddPicklistItemAction.cls
/**
* Copyright (c) 2015, FinancialForce.com, inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
@afawcett
afawcett / EV3DirectCommand.java
Created Oct 4, 2015
Lego EV3 MachineCloud Java Code
View EV3DirectCommand.java
package com.andyinthecloud.legoev3force.ev3kernal;
import lejos.hardware.Button;
import lejos.hardware.motor.Motor;
import lejos.hardware.port.SensorPort;
import lejos.hardware.sensor.EV3TouchSensor;
import lejos.robotics.SampleProvider;
import lejos.robotics.filter.AbstractFilter;
/**
@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;
You can’t perform that action at this time.