Skip to content

Instantly share code, notes, and snippets.

// records populated
List<SObject> records = ...;
Set<Id> recordIds = new Map<Id, SObject>(records).keySet();
global class Operation {
global class OperationRequest {
global String inputA { get; set; }
global Boolean inputB { get; set; }
// etc
}
global class OperationResponse {
public class InterfaceExample {
public interface A {
void operationA();
}
public interface B extends A {
void operationB();
}
}
public class ColorExample {
public enum Color {
Red,
Green,
Blue
}
public void adjust(Color c) {
if (c == color.Red) {
// 1,000 Accounts already exist in org.
List<Account> accounts =
[Select Id
from Account
limit 1000];
// Determine how much time to collect account ids from list using for each loop
DateTime fromListStart = DateTime.now();
Set<Id> accountIdsFromList = new Set<Id>();
@lfreeland
lfreeland / gist:397ff5db61e9749e63b48f0094d62b34
Created February 5, 2017 21:12
Lookup Dropdown Component Markup
<aura:component controller="LookupDropdownController"
implements="flexipage:availableForRecordHome,force:hasRecordId,force:hasSObjectName">
<aura:attribute name="lookupField" type="String" />
<aura:attribute name="lookupFieldLabel" type="String" />
<aura:attribute name="submitButtonLabel" type="String" default="Submit" />
<aura:attribute name="selectableRecords" type="List" />
<aura:attribute name="debugEnabled" type="String" />
<aura:handler name="init" value="{!this}" action="{!c.initLookupDropdown}" />
@lfreeland
lfreeland / gist:85354e9e37af1d125f6127892dee74d9
Last active March 2, 2017 16:09
Lookup Dropdown Designer Markup
<design:component>
<design:attribute name="lookupField" label="Lookup Field" description="API Name of the lookup field." />
<design:attribute name="submitButtonLabel" label="Submit Button Label" default="Submit" description="The label to show on the submit button." />
<design:attribute name="debugEnabled" label="Debug Enabled" datasource="Yes,No" default="No" description="When set to Yes, the diagnostic information is shown." />
</design:component>
@lfreeland
lfreeland / gist:23eaee426da504cda86facb17ec0a85d
Created February 5, 2017 21:31
Lookup Dropdown Designer Markup
<design:component>
<design:attribute name="lookupField" label="Lookup Field" description="API Name of the lookup field." />
<design:attribute name="submitButtonLabel" label="Submit Button Label" default="Submit" description="The label to show on the submit button." />
<design:attribute name="debugEnabled" label="Debug Enabled" datasource="Yes,No" default="No" description="When set to Yes, the diagnostic information is shown." />
</design:component>
@lfreeland
lfreeland / gist:c4ace2abd61c474f3031ecbe6b73a5f7
Last active March 2, 2017 16:09
Lookup Dropdown Component Controller
({
initLookupDropdown : function(component, event, helper) {
var action = component.get("c.loadLookupDropdown");
var objectName = component.get("v.sObjectName");
var lookupField = component.get("v.lookupField");
var recordId = component.get("v.recordId");
console.log("objectName: " + objectName);
console.log("lookupField: " + lookupField);
console.log("recordId: " + recordId);
@lfreeland
lfreeland / gist:a5978891738f025ee44f318b86d7a282
Created February 5, 2017 21:49
Lookup Dropdown Apex Controller
public with sharing class LookupDropdownController {
@auraEnabled
public static Context loadLookupDropdown(String objectName, String lookupField, Id recordId) {
Context c = new Context();
String[] types = new String[]{ objectName };
Schema.DescribeSobjectResult[] results = Schema.describeSObjects(types);
Schema.DescribeSobjectResult objectResult = results[0];