Skip to content

Instantly share code, notes, and snippets.

View zachelrath's full-sized avatar

Zach McElrath zachelrath

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / PendingApprovalItemsForUserGroups.xml
Created July 3, 2014 15:27
Skuid Page that shows Pending Approval Items for the User or for any Groups that the user is a part of, either directly or indirectly
<skuidpage showsidebar="true" showheader="true" tabtooverride="User">
<models>
<model id="UserGroups" limit="20" query="true" createrowifnonefound="false" sobject="Group">
<fields>
<field id="Name"/>
<field id="DeveloperName"/>
<field id="Type"/>
</fields>
<conditions>
<condition type="join" value="" field="Id" operator="in" enclosevalueinquotes="true" joinobject="GroupMember" joinfield="GroupId" logic="">
@zachelrath
zachelrath / Opportunity_withInlineEditablePreview.xml
Created May 7, 2014 18:03
An Opportunity detail page with a popup that lets you use a prototype Skuid markup language feature within "fragments" of HTML code to generate inline-editable Skuid Ui Fields
<skuidpage showsidebar="true" showheader="true" tabtooverride="Opportunity">
<models>
<model id="Opportunity" limit="1" query="true" createrowifnonefound="false" sobject="Opportunity">
<fields>
<field id="Name"/>
<field id="CreatedDate"/>
<field id="CloseDate"/>
<field id="Amount"/>
</fields>
<conditions>
<skuidpage showsidebar="true" showheader="true" tabtooverride="Opportunity">
<models>
<model id="SortOrders" limit="100" query="true" createrowifnonefound="false" sobject="Sort_Order__c">
<fields>
<field id="Sort_Order__c"/>
<field id="Skuid_Page__c"/>
<field id="Skuid_Page__r.Name"/>
<field id="Model_Id__c"/>
</fields>
<conditions>
@zachelrath
zachelrath / OpportunityDetail.xml
Created April 24, 2014 20:39
Opportunity Detail page with "Shopping Cart" for picking Products / Line Items
<skuidpage showsidebar="false" showheader="true" tabtooverride="Opportunity">
<resources>
<labels/>
<javascript>
<jsitem location="inline" name="markCompleted" url="">skuid.snippet.registerSnippet('tasks.markCompleted',function(params){
// Mark all selected items as closed,
// then save our 2 Tasks models
var model = params.model,
list = params.list,
selectedItems = params.item ? [params.item] : list.getSelectedItems();