This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Utility methods for use with the Object Snapshot object | |
* | |
* @author Patrick Connelly | |
*/ | |
public with sharing class ObjectSnapshotUtils { | |
public static String JSON_DELIMITER = '[delimiter]'; | |
public static Integer JSON_FIELD_SIZE = 32768 - (JSON_DELIMITER.length() * 2); | |
public static Integer JSON_FIELD_COUNT = 10; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Agent code | |
function send_pushover(title, message, priority) { | |
local url = "https://api.pushover.net/1/messages.json"; | |
local token="XXX_TOKENGOESHERE_XXX"; | |
local user="XXX_USERGOESHERE_XXX"; | |
local headers = { "Content-Type": "application/x-www-form-urlencoded" }; | |
local data = { | |
"token": token, | |
"user": user, | |
"message": message |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String extractRefId(String orgId, String testString) { | |
pattern myPattern = pattern.compile('(?m).*\\[ ref:(.*)\\.(.*):ref \\].*'); | |
matcher myMatcher = myPattern.matcher(testString); | |
if (myMatcher.matches()) { | |
if (myMatcher.group(1) == orgId) { | |
return myMatcher.group(2); | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Map<String, Profile> profileMap { | |
get { | |
if (profileMap == null) { | |
profileMap = new Map<String, Profile>(); | |
for (Profile p: [ | |
select Name | |
from Profile | |
]) { | |
profileMap.put(p.Name, p); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//This would actually be your CaseTrigger.trigger but the hilighting wouldn't work then | |
List<ChatterPost> postsToInsert = new List<ChatterPost>(); | |
for (Case c: trigger.new) { | |
if (c.Status == 'collab') { | |
postsToInsert.add(new ChatterPost(...)); | |
} | |
if (!postsToInsert.isEmpty()) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger CaseTrigger on Case (after insert) { | |
ObjectSnapshotUtils.createSnapshots(Trigger.new); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Map<DateTime, User> userMap = new Map<DateTime, User>(); | |
for (User u: [select LastLoginDate from User where Id in:userIds]) { | |
userMap.put(u.LastLoginDate, u); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Trigger AutoConverter on Lead (after insert) { | |
LeadStatus convertStatus = [ | |
select MasterLabel | |
from LeadStatus | |
where IsConverted = true | |
limit 1 | |
]; | |
List<Database.LeadConvert> leadConverts = new List<Database.LeadConvert>(); | |
for (Lead lead: Trigger.new) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Gets an admin user | |
* | |
* @return An admin user | |
*/ | |
public static User getAdminUser() { | |
Profile adminProfile = [ | |
select id | |
from profile | |
where name = 'System Administrator' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
System.debug(System.LoggingLevel.ERROR, '| vs ' + EncodingUtil.urlDecode('%7C;', 'UTF-8')); | |
if ('|' == EncodingUtil.urlDecode('%7C', 'UTF-8')) { | |
System.debug(System.LoggingLevel.ERROR, 'Expected: %7C'); | |
} else { | |
System.debug(System.LoggingLevel.ERROR, 'Unxpected: %7C'); | |
} | |
System.debug(System.LoggingLevel.ERROR, '| vs ' + EncodingUtil.urlDecode('|', 'UTF-8')); | |
if ('|' == EncodingUtil.urlDecode('|', 'UTF-8')) { | |
System.debug(System.LoggingLevel.ERROR, 'Expected: |'); |