Skip to content

Instantly share code, notes, and snippets.

@meajinkya
meajinkya / QueryBuilderV2.cls
Last active March 12, 2021 06:56
QueryBuilder v2
/***************************************************************************************************
* Copyright (c), FinancialForce.com, inc
* All rights reserved.
*
* Generic Query Builder class to handle generation of SOQL queries and query exection
* based on fflib QueryFactory
***************************************************************************************************/
public class QueryBuilder {
public enum SortOrder {ASCENDING, DESCENDING}
@meajinkya
meajinkya / LightningPCAttributes.txt
Created October 1, 2018 09:21
Parent/Child Message Passing using Attributes
<!-- Parent component "parent.cmp" -->
<aura:component>
<aura:attribute name="myAttr" type="String" default="world" />
<c:child myAttrChild="{!v.myAttr}">
</aura:component>
<!-- Child component "child.cmp" -->
<aura:component>
<aura:attribute name="myAttrChild" type="String"/>
<lightning:input name="input1" label="Enter some text" value="{!myAttrChild}" />
@meajinkya
meajinkya / CheckboxSelector.js
Created September 11, 2018 10:32
All Checkboxes Selector
(function() {
var allCheckboxes = document.querySelectorAll("input[type=checkbox]");
Array.from(allCheckboxes).forEach(
function(thisCheckbox) {
thisCheckbox.checked = true;
}
);
})();
@meajinkya
meajinkya / ApexTriggerApproach.txt
Created April 5, 2018 08:46
A good approach for Apex triggers
A good approach to follow for trigger development
Any trigger's logic can be looked at in three parts(as below) and the code for that should also be written based on those parts:
1. Trigger event detection
This should go in the trigger where we write logic for trigger event detection and delegation to appropriate method in handler class.
2. Record filtering
Record filtering can be done using a separate class which can have different methods for filtering for each action. It may happen that a filter can be applied to two different actions, for which we can reuse the same method for filtering.
3. Actions (Business logic)
This should be typically done in a service class. The records filtered in step #2 can be passed on to the service class to perform actions like creating child records, updating parent record, etc on them.