Skip to content

Instantly share code, notes, and snippets.

View leehildebrand's full-sized avatar

Lee Hildebrand leehildebrand

View GitHub Profile
@leehildebrand
leehildebrand / gist:5b503205cf1eeaaa82aae33faa33881d
Last active September 23, 2022 14:19
GrowthLink Sync Script
//SYNC UP WHERE CASE AND ISSUE EXIST
// Call Schema to get the report metadata
Reports.ReportMetadata reportMd = Reports.ReportManager.describeReport('00O3c000007LMmHEAW').getReportMetadata();
// Run the report and store the rows in a Reports.ReportFactWithDetail object
Reports.ReportFactWithDetails factDetails = (Reports.ReportFactWithDetails)Reports.ReportManager.runReport('00O3c000007LMmHEAW', reportMd, true).getFactMap().get('T!T');
// For each row the report returns, update the Case
for(Reports.ReportDetailRow detailRow : factDetails.getRows()){
HttpRequest req = new HttpRequest();
req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
@leehildebrand
leehildebrand / JSparameterFromVF.page
Last active June 21, 2017 16:14
Pass Parameter to JS from VF
<apex:commandButton value="Pass Parameter" onclick="run('{!Account}'); return false;" />
<script>
function run (record)
{
alert(record);
}
</script>
@leehildebrand
leehildebrand / .cls
Last active January 9, 2018 20:45
Populate StandardSetController from API
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());
<!-- *******************************
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.
/*******************************************************//**
@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.
/*******************************************************//**
@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 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;
@leehildebrand
leehildebrand / ProcessHandlerShowAccounts.cls
Last active May 13, 2020 21:30
Pass multiple, strongly typed parameters from Process Builder to Apex #1
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 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 / 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>