This file contains 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 class ChrisNamespace { | |
public static final String ns = Namespace; | |
public static final String nsUU = NamespaceUU; | |
public static String Namespace { | |
get { | |
if (Namespace != null) return Namespace; | |
ApexClass ac = [SELECT NameSpacePrefix FROM ApexClass WHERE Name = 'ChrisNamespace' limit 1]; | |
Namespace = ac.NameSpacePrefix != null ? ac.NameSpacePrefix : ''; |
This file contains 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
/* | |
Example code of how to upload an excel / pbix file to Power BI embedded | |
uses this API here: https://msdn.microsoft.com/en-us/library/mt243840.aspx | |
*/ | |
var group_id = '<app workspace id>'; | |
var access_token = '<power bi access token>'; |
This file contains 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
/* | |
* Hard coding your Salesforce URL in places like Email Tempaltes and Apex Classes is a worst practice, but some people do it. | |
* These URLs will break when you turn on my domain, since your URL changes. | |
* More on this here: https://help.salesforce.com/apex/HTViewSolution?urlname=Updating-Hard-Coded-References-FAQ | |
* Here are some quick and dirty checks for your Salesforce URL being hard coded in: | |
* EmailTemplates, WebLinks, ApexClasses, Visualforce Pages, and Triggers. | |
* Ideally you would retrieve all metadata and search it, but this will find some of the low hanging problems easily. | |
* | |
* Usage: | |
* - Copy / Paste this into Salesforce Execute Anonymous window. |
This file contains 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
<?php | |
//this requires the php toolkit: https://github.com/developerforce/Force.com-Toolkit-for-PHP | |
require_once ('settings.php'); | |
require_once ('phpToolkit/SforcePartnerClient.php'); | |
require_once ('phpToolkit/SforceHeaderOptions.php'); | |
$storage = checkStorageUsage($USERNAME, $PASSWORD, $ORG_ID); | |
$api = checkAPI($USERNAME, $PASSWORD, $ORG_ID); |
This file contains 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 class SupportPreChat { | |
public Contact theContact {get; set;} | |
public String endpoint {get; set;} | |
public String jsSubmitForm {get; set;} | |
public SupportPreChat() { | |
jsSubmitForm = ''; | |
theContact = new Contact(); |
This file contains 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 LeadConvertReparentChatTranscript on Lead (before update) { | |
Map<Id,Id> convertedLeadsWithContactIds = new Map<Id,Id>(); | |
for (Lead theLead:Trigger.new) { | |
Lead beforeUpdate = System.Trigger.oldMap.get(theLead.Id); | |
if ((theLead.ConvertedContactId != null) && (beforeUpdate.ConvertedContactId == null)) { | |
//if the converted contactId just went from not populated, to populated | |
//meaning we are converting the lead into a contact | |
convertedLeadsWithContactIds.put(theLead.Id,theLead.ConvertedContactId); |
This file contains 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 class SalesPreChat { | |
public Lead theLead {get; set;} | |
public Lead leadInsert {get; set;} | |
public String endpoint {get; set;} | |
public String jsSubmitForm {get; set;} | |
public SalesPreChat() { | |
jsSubmitForm = ''; | |
theLead = new Lead(); |
This file contains 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 class LeadUpdateOwnerChat { | |
//the ID of the anon user for the force.com site your prechat form is hosted on | |
static final Id SALES_SITE_GUEST_USER = '005000000000000'; | |
@future | |
public static void updateLeadOwner(Map<Id, Id> leadOwnerMap) { | |
//map coming has the key as the lead id and the value as the new owner id | |
//build a list of the Leads we need to change the owner on |
This file contains 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
//remove all the files from the local github repo which aren't in the metadata repo (in case these were objects which were deleted in salesforce) | |
//get the an array of each file listings, recursively. Strip off the beginning path from each entry in the array so we can do text comparison | |
$arrMetadata = stripBlanks(str_replace('/home/dpeter/sf/metadata', '', getFilesFromDir('/home/dpeter/sf/metadata'))); | |
$arrGit = stripBlanks(str_replace('/home/dpeter/sf/git/salesforce-metadata', '', getFilesFromDir('/home/dpeter/sf/git/salesforce-metadata'))); | |
//remove array entries in the /.git directory | |
$arrGit = stripGit($arrGit); | |
$arrDeleteFromGit = array(); |
This file contains 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
function searchReplaceBuildXmlFile($search, $replace) { | |
// Open file for read and string modification | |
$file = "/home/dpeter/sf/build.xml"; | |
$fh = fopen($file, 'r'); | |
$contents = fread($fh, filesize($file)); | |
$new_contents = str_replace($search, $replace, $contents); | |
fclose($fh); | |
// Open file to write | |
$fh = fopen($file, 'w'); |
NewerOlder