Skip to content

Instantly share code, notes, and snippets.

View leehildebrand's full-sized avatar

Lee Hildebrand leehildebrand

View GitHub Profile
@leehildebrand
leehildebrand / CarAuctionAPIChatterActionController.cls
Last active February 1, 2016 16:24
Car Auction API Chatter Action Controller
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Created By: Lee Hildebrand (http://leehildebrand.name)
//Created Date: 12/23/14
//Purpose: Use Lead data to connect to ARD web services and retrieve a "quote"
// then create either as "scrap" or "non-scrap assignment
//Revised:
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public with sharing class QuoteController {
private final Lead lead;
public String selectedService {get; set;}
@leehildebrand
leehildebrand / ForceRESTEndpoint.cls
Created February 1, 2016 16:25
Force.com REST Endpoint
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Author: Lee Hildebrand (http://leehildebrand.name)
//Date: 6/2/15
//Purpose: Provide APEXREST endpoint that allows for insert / update of Registered_User__c records
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@RestResource(urlMapping='/v.1/RegisteredUsersService/*')
global with sharing class RegisteredUsersService{
global class user_to_register {
Global String active;
Global String birth_year;
@leehildebrand
leehildebrand / TriggerFutureCallout.cls
Created February 1, 2016 16:48
TriggerFutureCallout
public class IntegrationController{
@future(callout=true)
public static void sendShift(String[] shifts){
HttpRequest req = new HttpRequest();
req.setEndpoint(API__c.getValues('Endpoint').Value__c);
req.setTimeout(120000);
req.setMethod('POST');
//req.setHeader('Authorization', 'Basic ' + EncodingUtil.base64Encode(Blob.valueOf(API__c.getValues('Username').Value__c+':'+API__c.getValues('Password').Value__c)));
req.setHeader('Authorization', 'Basic ' + EncodingUtil.base64Encode(Blob.valueOf(API__c.getValues('Username').Value__c+':'+API__c.getValues('Password').Value__c)));
req.setheader('Content-Type', 'text/xml');
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8">
<HEAD>
<script language="JavaScript" type="text/javascript">
function checkform ( form ){
if (form.name.value == "") {
alert( "Please enter your name." );
form.name.focus();
return false ;
}
if (form.email.value == "" && form.phone.value == "") {
@leehildebrand
leehildebrand / fieldLabelDemo.page
Last active February 2, 2017 16:58
VisualForce Schema Field Label
<apex:page standardController="Account">
<apex:form >
<!-- both inputFields below write to an Account field named Demo_Field__c -->
<apex:pageBlock >
<apex:pageBlockSection title="Developer 1 below used a static text to talk about the field label" columns="2">
I am talking about a field named "Demo Field"!
</apex:pageBlockSection>
<apex:pageBlockSection title="Developer 2 below used a schema variable to talk about the field label" columns="2">
I am talking about a field named "{!$ObjectType.Account.fields.Demo_Field__c.Label}"!
</apex:pageBlockSection>
@leehildebrand
leehildebrand / ReturnRecordsFromReport.apex
Last active February 3, 2017 18:12
Return sObject records from a report on a very large object (records>200k)
// Call Schema to get the report metadata
Reports.ReportMetadata reportMd = Reports.ReportManager.describeReport(AnalyticAPISupport__c.getValues('DemoAnalyticAPI').Report_Id__c).getReportMetadata();
//Get the relevant filter in Reports.ReportFilter type variable and set it to the Account Number I'm looking for
Reports.ReportFilter filter = reportMd.getReportFilters()[0];
filter.setValue('12345');
// Run the report and store the rows in a Reports.ReportFactWithDetail object
// Make sure to use the three parameter version of the Reports.ReportManager class runReport() method to:
// 1. Run the report with the filter we just set and...
// 2. Return a Reports.ReportFactWithDetails object (as opposed to a summary ReportFactWithSummaries object)
Reports.ReportFactWithDetails factDetails = (Reports.ReportFactWithDetails)Reports.ReportManager.runReport(AnalyticAPISupport__c.getValues('DemoAnalyticAPI').Report_Id__c, reportMd, true).getFactMap().get('T!T');
@leehildebrand
leehildebrand / ProcessHandlerShowOpps.cls
Created February 24, 2017 05:12
Pass multiple, strongly typed parameters from Process Builder to Apex #2
public class ProcessHandlerShowOpps {
public class OpportunityParameter{
@InvocableVariable(required=true)
public Id oppId;
@InvocableVariable(required=true)
public String name;
@InvocableVariable(required=true)
public Decimal amount;
@InvocableVariable(required=true)
public Date closeDate;
/*******************************************************//**
@trigger Trigger Name
@object Object that fires trigger
@brief Description of the class
@handler Handler Name
@author Developer Name (EMS.JobTitle)
@version Date 1 Developer Name (EMS.JobTitle) Purpose of the trigger
Date 2 Developer Name (EMS.JobTitle) - Purpose of the change
@bug No known defects.
@todo None.
/*******************************************************//**
@class Class Name
@brief Description of the class
@testClass Test Class Name
@author Developer Name (EMS.JobTitle)
@version Date 1 Developer Name (EMS.JobTitle) Purpose of the class
Date 2 Developer Name (EMS.JobTitle) - Purpose of the change
@bug No known defects.
@todo None.
@copyright (c)2017 EMS. All Rights Reserved. Unauthorized use is prohibited.
<!-- *******************************
Page: Page Name
Purpose: Page to add a BPGC portal file from the Case feed
Created On: Developer Name (EMS.JobTitle)
Created By: Date
Revision History:
1. Date (DeveloperName.JobTitle) Change purpose.