Skip to content

Instantly share code, notes, and snippets.

View zachelrath's full-sized avatar

Zach McElrath zachelrath

View GitHub Profile
@zachelrath
zachelrath / gist:3976677
Created October 29, 2012 21:32
Dynamic Method invocation in Apex
public interface Executable {
void execute(String method);
}
public class DoAwesomeStuff implements Executable {
public override void execute(String method) {
if (method == 'method1') method1();
else if (method == 'method2') method2();
}
@zachelrath
zachelrath / gist:4488190
Created January 8, 2013 21:34
SOQL query for all Profiles with delete Permissions on an Sobject
SELECT Id,PermissionsDelete,Parent.Profile.Name,SobjectType
FROM ObjectPermissions
WHERE Parent.IsOwnedByProfile = TRUE
AND PermissionsDelete = TRUE
ORDER BY Parent.Profile.Name, SObjectType
@zachelrath
zachelrath / quantityRenderer
Created March 30, 2013 14:54
Inline Snippet field renderer for the Quantity field on OpportunityLineItem object. Forces a concurrent update of the UnitPrice/SalesPrice field whenever Quantity is updated.
var field = arguments[0],
value = arguments[1];
if (field.mode == 'read') {
skuid.ui.fieldRenderers.DOUBLE.read(field,value);
} else {
skuid.ui.fieldRenderers.DOUBLE.edit(field,value);
skuid.utils.delayInputCallback(
@zachelrath
zachelrath / truncateDecimalPoints
Created April 15, 2013 21:17
Inline Snippet field renderer for Skuid --- eliminates decimal places on any Double, Percent, or Currency display type fields that it is applied to
var field = arguments[0],
value = arguments[1],
metadata = field.metadata,
dt = metadata.displaytype;
// For currency, double, and percent fields,
// manually override the field's metadata
// related to how many decimal points to display
if (dt == 'CURRENCY' || dt == 'DOUBLE' || dt == 'PERCENT') {
metadata.scale = 0;
@zachelrath
zachelrath / jQuery vs. DOM Native Methods: Check all checkboxes in a page
Last active February 7, 2020 16:50
Comparison of the complexity between jQuery and DOM Native syntax required to find all checkboxes in a given page and automatically check them.
// jQuery
$('input[type="checkbox"]').prop('checked',true);
// DOM
Array.prototype.slice.call(document.querySelectorAll('input[type="checkbox"]')).forEach(function(e){e.setAttribute("checked","checked");});
@zachelrath
zachelrath / Load Skuid using <skuid:page> component instead of page action method
Last active December 18, 2015 16:09
How to use the <skuid:page> Visualforce component to load Skuid instead of page action method
// If your Visualforce Page currently looks like this:
<apex:page action="{!redirect}&objecttype=Account&actiontype=View" standardController="Account"/>
// Change it to look like this:
<apex:page standardController="Account" readonly="true" doctype="html-5.0">
<skuid:page objectType="Account" actionType="View"/>
</apex:page>
@zachelrath
zachelrath / Multi-select Picklist renderer
Created October 1, 2013 15:40
Skuid custom field renderer to make any Field into a Multi-select Picklist
//
// SETTINGS
//
var POSSIBLE_PICKLIST_VALUES = [
'Education',
'College Counseling',
'Job Club',
'Full Medical & Dental Care',
'Mental Health',
@zachelrath
zachelrath / Sync PermissionSetAssignments with Custom Setting field
Created October 1, 2013 18:54
Skuid Snippets for adding/removing PermissionSetAssignments based on the value of a field in Custom Setting record(s)
// Row Action snippet
skuid.snippet.registerSnippet('SyncPermSets_RowAction',function(){
skuid.snippet.getSnippet('UpdatePermissionSetAssignmentsForUsers')({
rows:[arguments[0].item.row]
});
});
// Mass Action snippet
skuid.snippet.registerSnippet('SyncPermSets_MassAction',function(){
var rows = [];
@zachelrath
zachelrath / NewCaseWithMap.xml
Created March 12, 2014 18:17
Skuid Page XML for "NewCaseWithMap" example
<skuidpage showsidebar="true" showheader="true" tabtooverride="Case">
<models>
<model id="Case" limit="1" query="false" createrowifnonefound="true" sobject="Case">
<fields>
<field id="Subject"/>
<field id="Status"/>
<field id="Priority"/>
<field id="Latitude__c"/>
<field id="Longitude__c"/>
</fields>
@zachelrath
zachelrath / LogACaseWeb.xml
Created March 25, 2014 23:00
Skuid Page XML for logging a Case from a Force.com Site and pre-creating a skuid__Image__c record that gets thrown into a "skuid__Photo__c" field on the new Case.
<skuidpage showsidebar="true" showheader="true" tabtooverride="Case">
<models>
<model id="CasePhoto" limit="1" query="false" createrowifnonefound="true" sobject="skuid__Image__c">
<fields/>
<conditions/>
</model>
<model id="Case" limit="1" query="false" createrowifnonefound="true" sobject="Case">
<fields>
<field id="Subject"/>
<field id="Description"/>