Skip to content

Instantly share code, notes, and snippets.

View agentgill's full-sized avatar

Mike Gill agentgill

View GitHub Profile
@agentgill
agentgill / gist:e006cb2c8d2dc9bc4fac
Last active August 29, 2015 14:10
Sample Print Extension (PDF)
/*
* @description: this class extends the standard opportunity object providing an action which attachs the PDF as an attachment against the opportunity
*
* @TODO's:
*/
public class PrintExtension{
// Create standard object controller
/*
@description: Controller Extension used by Flow
@date: 13th April 2015
@author: Salesforce Weekly
*/
public class ClosedLoopMarketingFlowExtension {
private final Contact cont;
private PageReference pageRef;
@agentgill
agentgill / ClosedLoopMarketingDemoPage
Created June 7, 2015 20:44
ClosedLoopMarketingDemoPage
<apex:page standardController="Contact" extensions="ClosedLoopMarketingFlowExtension" >
<flow:interview name="Closed_Loop_Marketing_Demo_Part_1"
interview="{!myFlow}"
finishLocation="{!FinishLocation}">
<apex:param name="varContactId" value="{!Contact.Id}"/>
</flow:interview>
</apex:page>
@agentgill
agentgill / AutocompleteController.cls
Created March 14, 2018 19:34 — forked from peterknolle/AutocompleteController.cls
Lightning Autocomplete Component
public class AutocompleteController {
@AuraEnabled
public static List<sObject> getSuggestions(String sObjectType, String term, String fieldsToGet, Integer limitSize) {
// could add in logic to remove possible duplicate fields
String fields = fieldsToGet.length() > 0 ? ',' + fieldsToGet : '';
String soql =
' SELECT Name, Id ' + String.escapeSingleQuotes(fields) +
' FROM ' + String.escapeSingleQuotes(sObjectType) +
' WHERE Name Like \'' + String.escapeSingleQuotes(term) + '%\'' +
@agentgill
agentgill / README.md
Created March 29, 2018 18:00 — forked from hofmannsven/README.md
My simply Git Cheatsheet
global class XmlToJson {
// Try to determine some data types by pattern
static Pattern
boolPat = Pattern.compile('^(true|false)$'), decPat = Pattern.compile('^[-+]?\\d+(\\.\\d+)?$'),
datePat = Pattern.compile('^\\d{4}.\\d{2}.\\d{2}$'),
timePat = Pattern.compile('^\\d{4}.\\d{2}.\\d{2} (\\d{2}:\\d{2}:\\d{2} ([-+]\\d{2}:\\d{2})?)?$');
// Primary function to decode XML
static Map<Object, Object> parseNode(Dom.XmlNode node, Map<Object, Object> parent) {
// Iterate over all child elements for a given node
for(Dom.XmlNode child: node.getChildElements()) {
@agentgill
agentgill / PopulateNestedMapPattern
Last active July 22, 2018 14:39
Salesforce APEX - Populate Nested Map Pattern
for ( Sobject sobj : someList ){
Map<Id, SObject> innerMap = mainMap.containsKey( sobj.outer )
? mainMap.get( sobj.outerId ) : new Map<Id, SObject>();
innerMap.put( sobj.innerId, sobj );
mainMap.put( sobj.outerId, innerMap );
}
@agentgill
agentgill / package.xml
Created April 1, 2018 10:42
Empty package.xml v42.0
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<version>42.0</version>
</Package>
@agentgill
agentgill / QueryObjectSchemaRelationships
Created April 2, 2018 09:04
SOQL query for outputting object schema for related set of objects
for(Schema.SobjectField strFld: Loan_New__c.SobjectType.getDescribe().fields.getMap().Values())
{
if(strFld.getDescribe().getType() == Schema.DisplayType.REFERENCE)
{
system.debug('object:'+strFld.getDescribe().getReferenceTo());
}
}
Schema.DescribeSObjectResult R = Loan_New__c.SObjectType.getDescribe();
for (Schema.ChildRelationship cr: R.getChildRelationships())
{
"nonBorrowingResidents": [
{
"relationship_to_client": "Uncle",
"name": "NBR-38",
"monthly_income": 456345.00,
"date_of_birth": "1923-03-01",
"non_borrowing_resident_name": "fgh",
"loan_id": "a0Q29000002ooRuEAI",
"last_modified_by_id": "00529000001A6eCAAS",