Skip to content

Instantly share code, notes, and snippets.

View leehildebrand's full-sized avatar

Lee Hildebrand leehildebrand

View GitHub Profile
@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());
@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 / 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());