Skip to content

Instantly share code, notes, and snippets.

Lee Hildebrand leehildebrand

View GitHub Profile
@leehildebrand
leehildebrand / JSparameterFromVF.page
Last active Jun 21, 2017
Pass Parameter to JS from VF
View JSparameterFromVF.page
<apex:commandButton value="Pass Parameter" onclick="run('{!Account}'); return false;" />
<script>
function run (record)
{
alert(record);
}
</script>
@leehildebrand
leehildebrand / .cls
Last active Jan 9, 2018
Populate StandardSetController from API
View .cls
public ApexPages.StandardSetController itemsSetController{
get{
if(itemsSetController == null) {
Item__c[] items = new Item__c[]{};
HttpRequest req = new HttpRequest();
req.setEndpoint('https://'+URL.getSalesforceBaseUrl().getHost()+'/services/data/v35.0/query/?q=SELECT+Id,Name+FROM+Item__c+WHERE+'where_clause'+ORDER+BY+Name+ASC');
req.setMethod('GET');
req.setHeader('Authorization', 'Bearer '+ userInfo.getsessionId());
Boolean done = false;
do{ JSONParser parser = JSON.createParser(new Http().send(req).getBody());
View VF Page Header
<!-- *******************************
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.
View Apex Class Header
/*******************************************************//**
@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.
View Apex Trigger Header
/*******************************************************//**
@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.
@leehildebrand
leehildebrand / ProcessHandlerShowOpps.cls
Created Feb 24, 2017
Pass multiple, strongly typed parameters from Process Builder to Apex #2
View ProcessHandlerShowOpps.cls
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;
@leehildebrand
leehildebrand / ProcessHandlerShowAccounts.cls
Last active May 13, 2020
Pass multiple, strongly typed parameters from Process Builder to Apex #1
View ProcessHandlerShowAccounts.cls
public class ProcessHandlerShowAccounts {
public class AccountParameter{
@InvocableVariable(required=true)
public Id accountId;
@InvocableVariable(required=true)
public String name;
}
@InvocableMethod(label='handleNewAccounts'
description='Reconstitue the Accounts being inserted based on the variables passed from Process Builder'
category='AccountCategory')
@leehildebrand
leehildebrand / ReturnRecordsFromReport.apex
Last active Feb 3, 2017
Return sObject records from a report on a very large object (records>200k)
View ReturnRecordsFromReport.apex
// 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 / fieldLabelDemo.page
Last active Feb 2, 2017
VisualForce Schema Field Label
View fieldLabelDemo.page
<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>
View WebToLead.html
<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 == "") {
You can’t perform that action at this time.