Skip to content

Instantly share code, notes, and snippets.

View conrjac's full-sized avatar
🪁
Focusing

Connor Jackson conrjac

🪁
Focusing
View GitHub Profile
@conrjac
conrjac / .gitignore
Created November 2, 2016 13:25
SalesForce Git Ignore
.project
.settings
.metadata
salesforce.schema
Referenced Packages
*.sublime-project
*.sublime-settings
*.sublime-workspace
apex-scripts/log
build.properties
@conrjac
conrjac / mergeCSVFiles.ps1
Created November 17, 2016 09:52
Powershell Script to merge multiple CSV files into one (by appending each file to the end)
$files = Get-ChildItem [INPUT FOLDER PATH - e.g C:\Data\]*.csv
Get-Content $files | Set-Content [OUTPUT FILE PATH - e.g C:\Data\MergedCsvFile.csv]
@conrjac
conrjac / SomeJSON.json
Created August 9, 2017 08:31
SomeJSON
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
@conrjac
conrjac / ApexJSON.cls
Created August 9, 2017 08:33
Apex Class of SomeJSON.json
public class JsonParser{
public glossary glossary{get;set;}
public class GlossList{
public GlossEntry GlossEntry{get;set;}
}
public class GlossEntry{
public String Abbrev{get;set;}
public String Acronym{get;set;}
public String GlossTerm{get;set;}
public GlossDef GlossDef{get;set;}
@conrjac
conrjac / convertISO8601.cls
Created December 13, 2017 14:47
convert ISO8601 dates to SalesForce DateTime
public DateTime convertISO8601(string str)
{
return (DateTime)json.deserialize('"' + str + '"', datetime.class);
}
import-module activedirectory
$DaysInactive = 90
$time = (Get-Date).Adddays(-($DaysInactive))
# Get all AD computers with lastLogonTimestamp less than our time
Get-ADComputer -Filter {LastLogonTimeStamp -lt $time -and OperatingSystem -notlike "*server*"} -Properties LastLogonTimeStamp,OperatingSystem |
# Output hostname and lastLogonTimestamp into CSV
select-object Name | export-csv C:\OLD_Computers.csv -notypeinformation
cat C:\OLD_Computers.csv | Get-ADComputer | Remove-ADObject
@conrjac
conrjac / vCalendarPage.html
Created August 9, 2018 08:37 — forked from douglascayers/vCalendarPage.html
Create .ics Calendar Event in Visualforce
<!--
Simple proof-of-concept to create a .ics calendar event with visualforce.
Inspired by Natalie Regier @gnatrae
This example uses url parameters to set the details of event.
You could create a custom button that invokes this page, like:
https://<your-salesforce-domain>/apex/vCalendarPage?start={!TEXT(Obj.StartDate__c)}&end={!TEXT(Obj.EndDate__c)}&subject=Event from Visualforce&description=This .ics event created with visualforce&location=The Cloud
An example with literal values you can copy & paste in your browser:
https://<your-salesforce-domain>/apex/vCalendarPage?start=20140524T140000&end=20140524T153000&subject=Event from Visualforce&description=This .ics event created with visualforce&location=The Cloud

Keybase proof

I hereby claim:

  • I am conrjac on github.
  • I am conrjac (https://keybase.io/conrjac) on keybase.
  • I have a public key ASDcqqS9qBjEwNjtnSZHhXk7foPhh8TexW8ywhY6aYXNMwo

To claim this, I am signing this object:

@conrjac
conrjac / IdeaCommentTriggerHandler.apxc
Created June 25, 2019 10:53
IdeaCommentTriggerHandler
public class IdeaCommentTriggerHandler {
public static void handleTrigger(List<IdeaComment> workingRecords, List<IdeaComment> oldRecords, System.TriggerOperation triggerEvent ) {
final Id orgWideAddress = [select Id from OrgWideEmailAddress WHERE Address ='[email protected]'].Id; // You should consider using a custom setting to manage this - certainly do not hardcode an address Id!
switch on triggerEvent {
when AFTER_INSERT, AFTER_UPDATE{