Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / DebugLog.txt
Last active March 13, 2019 04:26
Can anyone replicate this error?
45.0 APEX_CODE,FINEST;APEX_PROFILING,FINEST;CALLOUT,FINEST;DB,FINEST;NBA,INFO;SYSTEM,FINEST;VALIDATION,FINEST;VISUALFORCE,FINEST;WAVE,INFO;WORKFLOW,FINEST
Execute Anonymous: class kkkkkkk {
Execute Anonymous: void method1() { }
Execute Anonymous: }
Execute Anonymous: new kkkkkkk().method1();
00:25:56.1 (1554571)|USER_INFO|[EXTERNAL]|00550000000wTdS|<redacted>|(GMT-04:00) Eastern Daylight Time (America/Indiana/Indianapolis)|GMT-04:00
00:25:56.1 (1597258)|EXECUTION_STARTED
00:25:56.1 (1605985)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex
00:25:56.1 (1913868)|HEAP_ALLOCATE|[72]|Bytes:3
00:25:56.1 (1984554)|HEAP_ALLOCATE|[77]|Bytes:152
@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.script
Created January 8, 2019 05:14
Let's Use 51 MB of Heap Without LimitException
string[] s = new string[0];
for(integer i = 0; i < 10100; i++) {
s.add('*'.repeat(i));
}
system.debug(Limits.getHeapSize());
@brianmfear
brianmfear / demo1.app
Last active December 23, 2018 08:05
aura:if breaks again.
<aura:application >
<aura:attribute name="value1" type="String" access="private" />
<aura:attribute name="value2" type="String" access="private" />
<lightning:input value="{!v.value1}" label="Value 1" placeholder="Enter 'a'" />
<aura:if isTrue="{!v.value1 eq 'a'}">
<lightning:input value="{!v.value2}" label="Value 2" placeholder="Enter 'b'" />
<aura:if isTrue="{!v.value2 eq 'b'}">
<lightning:input label="Value 3" value="{!join(' ',v.value1,v.value2)}" />
</aura:if>
</aura:if>
@brianmfear
brianmfear / samplecombobox.app
Created October 9, 2018 20:08
Sample combobox Lightning
<aura:application extends="force:slds">
<aura:attribute name="contactFields" type="Contact" default="{sobjectType:'Contact',Gender__c:'Male',Partner_Gender__c:'Female'}" />
<aura:attribute name="genderOptions" type="List" default="[{label:'Male',value:'Male'},{label:'Female',value:'Female'},{label:'Not Specified/Other',value:'Not Specified/Other'}]" />
<lightning:combobox name="applicantgender" label="Applicant Gender" value="{!v.contactFields.Gender__c}" placeholder="Select Gender" options="{! v.genderOptions }" />
<lightning:combobox name="partnergender" label="Partner Gender" value="{!v.contactFields.Partner_Gender__c}" placeholder="Select Gender" options="{! v.genderOptions }" />
Applicant Gender: {!v.contactFields.Gender__c}<br />
Partner Gender: {!v.contactFields.Partner_Gender__c}
</aura:application>
@brianmfear
brianmfear / DemoBundle.cmp
Created September 18, 2018 16:50
Disable button when all select options selected (Lightning)
<aura:application >
<aura:attribute name="opts" type="String[]" default="['A','B','C']" />
<aura:attribute name="disableButton" type="Boolean" default="false" />
<select aura:id="picklist" onchange="{!c.updateButtonState}" multiple="multiple">
<aura:iteration items="{!v.opts}" var="opt">
<option value="{!opt}">{!opt}</option>
</aura:iteration>
</select>
<lightning:button label="Test Button" disabled="{!v.disableButton}" />
</aura:application>
@brianmfear
brianmfear / TriggerDmlHelper.apex
Created August 27, 2018 23:08
Example of mapping related records to report errors on (Apex Code)
// Help report errors to parent/child object on failed DML update
// For use in Trigger contexts only.
// This version is for demonstration purposes only, and should not
// be considered production ready without additional modifications.
//
// Example trigger:
//
// trigger updateContactPhone on Account(after update) {
// Id[] updates = new Id[0];
// for(Account record: Trigger.new) {
@brianmfear
brianmfear / Debug.output
Created July 14, 2018 19:13
System.debug Fixes Your HashCodes
USER_DEBUG [5]|DEBUG|null
USER_DEBUG [6]|DEBUG|{Account:{Name=Test, Id=0015000001wL7JRAA0}=42}
USER_DEBUG [7]|DEBUG|42