Skip to content

Instantly share code, notes, and snippets.

@brianmfear
brianmfear / WizardDemoController.cls
Created February 6, 2019 13:11
Demo Two Page VF Wizard With Components And Data Sharing
public class WizardDemoController {
public WizardDemoController getSelf() {
return this;
}
public String message { get; set; }
public Integer pageNumber { get; set; }
public WizardDemoController() {
pageNumber = 1;
}
public void nextPage() {
@brianmfear
brianmfear / executeAnonymous.java
Created April 6, 2019 13:43
Example Reference and Heap Usage
// Technical Note: We can't add any strings to the debug logs
// because strings go in to a "string pool", which affects
// heap size for each non-unique string.
// Base heap
System.debug(Limits.getHeapSize());
// The "symbol table" has a new entry added, +0 heap
// i is defined, no value (heap does not change)
Integer i;
@brianmfear
brianmfear / Code39Controller.apxc
Last active April 15, 2019 19:41
Basic Code 39 In Visualforce
public class Code39Controller {
// Determines if the check digit should be generated
// If true, scanners must be enabled to use it
public Boolean shouldCheckDigit { get; set; }
// The source string to use. Currently only supports
// the characters in the "keys" string. Do not use '*'.
public String sourceCodeValue { get; set; }
// The index for supported characters.
static String keys = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%*';
@brianmfear
brianmfear / AccountData.cls
Last active January 29, 2020 15:41
lightning:tree with account hierarchy recursion example
public class AccountData {
@AuraEnabled public static Account[] getRecords() {
return [SELECT Name, ParentId, (SELECT Name FROM Contacts) FROM Account];
}
}
@brianmfear
brianmfear / q292183.app
Created February 13, 2020 14:14
Demo of using @AuraEnabled without getter/setter in both Aura and LWC (SFSE: 292183)
<aura:application controller="q292183">
<aura:handler name="init" value="{!this}" action="{!c.init}" />
<aura:attribute name="data" type="Map" />
{!v.data.a} {!v.data.b} {!v.data.c}
<hr />
<c:q292183lwc />
</aura:application>
@brianmfear
brianmfear / TreeNodeDataProvder.apxc
Created February 28, 2018 15:41
Recursive Tree in Lightning Demo
public class TreeNodeDataProvider {
@AuraEnabled public static User[] getUsers() {
return [SELECT Name, ManagerId, SmallPhotoUrl FROM User];
}
}
@brianmfear
brianmfear / filter.app
Created January 26, 2018 17:22
Lightning Add/Filter List
<aura:application extends="force:slds">
<!-- All items added to the list -->
<aura:attribute name="data" type="List" default="[]" />
<!-- The list of currently viewable items -->
<aura:attribute name="filteredData" type="List" default="[]" />
<!-- Input for a new item -->
<aura:attribute name="newItem" type="String" />
<!-- Input for the filter text -->
<aura:attribute name="filter" type="String" />
<aura:application extends="force:slds" controller="AccountListFilterByCity">
<aura:attribute name="cities" type="List" default="[]" />
<aura:attribute name="allAccounts" type="List" default="[]" />
<aura:attribute name="filterAccounts" type="List" default="[]" />
<aura:handler name="init" value="{!this}" action="{!c.init}" />
<lightning:layout>
<lightning:layoutItem size="3">
<aura:iteration items="{!v.cities}" var="cityValue">
namespace NumberGenerators {
public class UniqueNumberGenerator
{
int value;
public UniqueNumberGenerator(int value)
{
this.value = value;
}
public Nullable<int> NextId()
public class ServerSide50KPagination {
Id[] recordIds;
public Integer maxPage { get; set; }
public Integer pageNumber { get; set; }
public Integer pageSize { get; set; }
public Account[] records { get; set; }
public ServerSide50KPagination() {
recordIds = new Id[0];
for(Account record: [SELECT Id FROM Account ORDER BY Name]) {