Skip to content

Instantly share code, notes, and snippets.

View sfboss's full-sized avatar

SFDCBoss sfboss

View GitHub Profile
@sfboss
sfboss / EmailContentDocIdsApex.cls
Last active November 15, 2022 02:14
This is the code to have content doc ids emailed to you
// get the contentDocumentIds in the system and put them in a list to use for CDL query
// after we have our CDL Query, use the list of included objects to loop through and decide if the ContentDocumentId makes the cut for our final list of contentDocumentIds
// take the final list and make it 1 contentdocumentid per line and attach it to the running users record
// file is content-doc-ids.txt and it should be placed in the folder where you are running the script where the logs/content-doc-ids.txt file is (if the script ran already, you should see the old file there)
/**
BELOW IS ALL THAT SHOULD NEED EDITED TO BE ABLE TO USE .... PUT API NAMES AND RUN IT AND HOPE TO GET AN EMAIL
*/
String[] objectsToInclude = new List<String>{'Account','Contact','User'};
@sfboss
sfboss / sfrestapi_query_insert.cls
Last active November 12, 2022 10:09
This is a way to achive REST API interaction
public class qqSign_OAUTH_Handler implements Schedulable, Database.AllowsCallouts {
public String CONNECTEDAPP_CONSUMERID = '';
public String CONNECTEDAPP_CONSUMERSECRET = '';
public String SFUSERNAME = '';
public String SFPASS = '';
public void execute(SchedulableContext SC){
run();
}
@sfboss
sfboss / Validate Exception
Created November 5, 2022 03:07
validates an exception happened
public static void testValidation() {
Boolean threwException = false;
try {
// magical test method logic here
} catch (Exception e) {
threwException = true;
Boolean expectedExceptionThrown = (e.getMessage().contains(validationString)) ? true : false;
system.AssertEquals(true, expectedExceptionThrown, e.getMessage());
}
system.assertEquals(true, threwException, 'No exception was thrown');
@sfboss
sfboss / export.json
Created November 4, 2022 23:38
The minimal config for a Files Export/Import of the Account object
{
"objects": [
{
"operation": "Upsert",
"externalId": "Name",
"query": "SELECT Name FROM Account",
"afterAddons" : [
{
"module": "core:ExportFiles",
@sfboss
sfboss / PDFPage.page
Created October 16, 2022 10:17
PDFPage.page
‎‎​
@sfboss
sfboss / PDFController.cls
Last active October 16, 2022 10:17
PDFController
public without sharing class PDF_BidSubmissionLPController {
public Map<Integer, List<Bid__c>> bidsMap { get; set; }
public Bid__c thebid { get; set; } // used by the page to avoid a repeat when we know that we will only have 1 bid
public Housing__c housing { get; set; } // individual Stay data for the bid in question (child of bid will be RoomTypes and the Stay will be parent of the Bid and be just a one to many.
public Revenue__c therevenue { get; set; } // used to show commission data
public PDF_BidSubmissionLPController() {
List<Revenue__c> searchRevenue = [
@sfboss
sfboss / pdf.cls
Last active October 16, 2022 10:18
PDF Save in Apex
public static void savePDFFromCommunity(String bidId, String fileName, String visualForcePage) {
try {
List<Bid__c> bids = [
SELECT
Id,
UUID_For_Landing_Page__c,
Vendor__r.Name,
Housing__r.Id,
City__r.Name,
Housing__r.Name,
Http httpObject = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('http://fakeendpoint.com');
request.setHeader('Content-Type', 'application/json');
request.setMethod('POST');
HttpResponse response = httpObject.send(request);
String responseBody = response.getBody();
@sfboss
sfboss / HTTPRequest_Apex
Created October 6, 2022 02:56
An example HttpRequest in Apex
Http httpObject = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('http://fakeendpoint.com');
request.setHeader('Content-Type', 'application/json');
request.setMethod('POST');
HttpResponse response = httpObject.send(request);
String responseBody = response.getBody();
status
mixed_content_url
canonical
is_canonical
request_time
title
h1
page_date
description
keywords