Skip to content

Instantly share code, notes, and snippets.

Andrew Fawcett afawcett

View GitHub Profile
@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 / CustomMetadataService.cls
Last active Jun 12, 2018
Custom Metadata POC for DLRS
View CustomMetadataService.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 / 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 / CustomPermissionsReader.cls
Last active Jul 10, 2020
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 / Mock.cls
Last active Apr 17, 2020
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 / build.xml
Created Nov 16, 2014
ev3force build script...
View build.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project name="ev3" default="clean" basedir=".">
<!-- DEVELOPMENT SECTION -->
<property name="environment" value="EV3" />
<property name="project" value="ev3force"/>
<property name="version" value="0.1"/>
<property name="base.dir" value="." />
<property name="src" location="src"/>
<property name="lib" location="${base.dir}/lib" />
@afawcett
afawcett / OpportunitiesSelectorAfter
Last active Aug 29, 2015
Preview of QueryFactory, CRUD Security and FLS in Selector Layer (see comments below)
View OpportunitiesSelectorAfter
public with sharing class OpportunitiesSelector extends fflib_SObjectSelector
{
public List<Schema.SObjectField> getSObjectFieldList()
{
return new List<Schema.SObjectField> {
Opportunity.AccountId,
Opportunity.Amount,
Opportunity.CloseDate,
Opportunity.Description,
Opportunity.ExpectedRevenue,
@afawcett
afawcett / Opportunities.cls
Created Jun 20, 2014
Preview of FLS Support in Domain Layer (see comments below)
View Opportunities.cls
public with sharing class Opportunities extends fflib_SObjectDomain
{
public Opportunities(List<Opportunity> sObjectList)
{
// Domain classes are initialised with lists to enforce bulkification throughout
super(sObjectList);
}
public override void onApplyDefaults()
{
@afawcett
afawcett / gist:11156378
Created Apr 21, 2014
Attempt to create Standard Pricebook2 via JSON deserialize... fail sadly...
View gist:11156378
@IsTest
private with sharing class TestPricebook {
@IsTest private static void testPricebook()
{
System.assertEquals(0, [select Id from Pricebook2 where IsStandard = true].size());
Pricebook2 pb = (Pricebook2) JSON.deserialize('{"Name":"Standard", "IsStandard":"true"}', Pricebook2.class);
System.assertEquals(true, pb.IsStandard);
insert pb;
System.assertEquals(1, [select Id from Pricebook2 where IsStandard = true].size());
}
@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');
You can’t perform that action at this time.