Skip to content

Instantly share code, notes, and snippets.

View britishboyindc's full-sized avatar

Peter Churchill britishboyindc

View GitHub Profile
@britishboyindc
britishboyindc / gist:8428614
Created January 15, 2014 00:24
Adding Feed Item into a Chatter Feed of Opportunity (source) object for a new Grant Record (Target)
Opportunity opty = new Opportunity(Id = '006i000000A0T3t');
Grant_Management__c grd = new Grant_Management__c(Name = 'Test 123');
insert grd;
ConnectApi.FeedItemInput input = new ConnectApi.FeedItemInput();
ConnectApi.MessageBodyInput messageInput = new ConnectApi.MessageBodyInput();
ConnectApi.TextSegmentInput textSegment;
ConnectApi.LinkSegmentInput linkSegment;
messageInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();
@britishboyindc
britishboyindc / gist:8447044
Created January 15, 2014 23:43
Twilio Message List
This worked for me:
Map<String, String> params = new Map<String, String> ();
TwilioRestClient client = TwilioAPI.getDefaultClient();
TwilioMessageList als = new TwilioMessageList(client, params);
als.setRequestAccountSid('XXX'); //put Accound Sid here
for (TwilioMessage msg: als.getPageData()) {
system.debug('###' + msg.getProperty('body'));
}
@britishboyindc
britishboyindc / Test Script
Created May 22, 2014 02:48
Associate Contact with no Account Id to Bucket Account
@isTest
private class ContactAssociateAccount_TEST {
@isTest
private static void testblankaccountid() {
//First test when no Account exists
Contact testc = new Contact (LastName = 'Test Contact 1');
insert testc;
@britishboyindc
britishboyindc / gist:ca03b81c1167c2ac5fd3
Created September 30, 2015 20:08
svg#close causing JS error
html += '<tr><td><button class="slds-button slds-button--icon-bare removeKWRow"><svg aria-hidden="true" class="slds-button__icon slds-button__icon--large">';
html += '<use xlink:href="{!URLFOR($Resource.SLDS090,'/assets/icons/utility-sprite/svg/symbols.svg#close')}"></use>';
html +='<span class="slds-assistive-text">close</span></button></td>';
html += '<td>' + value.AccountName + '</td>';
html += '<td class="hiderow">' + value.AccountId + '</td>';
html += '<td class="hiderow">' + value.KnowWhoId + '</td>';
html += '<td>';
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration>
<appender name="fileAppender" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="${java.io.tmpdir}/sdl.log" />
<param name="Append" value="true" />
<param name="MaxFileSize" value="100KB" />
<param name="MaxBackupIndex" value="1" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
List<ApexClass> ac = [select Id, name, body from ApexClass where NamespacePrefix = NULL ];
integer i = 0;
for (ApexClass actemp: ac) {
if (actemp.body.contains( '@isTest') ) {
i++;
}
}
system.debug(i + ' classes are Tests');
trigger Employee_Demo on Employee__c (after insert, after update) {
//Create a map of the leaves for each Gender/Status Combo. Consider a setting for this
Map<String, List<String> > LeaveTypeMap = new Map<String, List<String> > ();
LeaveTypeMap.put('Female:Full Time', new List<String>{'Maternity Leave','Annual Leave','Personal Leave','Unpaid Leave'});
LeaveTypeMap.put('Male:Full Time', new List<String>{'Paternity Leave','Annual Leave','Personal Leave','Unpaid Leave'});
LeaveTypeMap.put('Female:Part Time', new List<String>{'Unpaid Leave'});
LeaveTypeMap.put('Male:Part Time', new List<String>{'Unpaid Leave'});
//Create list to hold new leave records
List<Leave__c> LeavestoCreate = new List<Leave__c> ();
//Is this an insert? If so, just create records
//Assume Asset object has name, lookup to user and picklist called Category
//Store results in a map
Map <String, List<String> > assetmap = new Map <String, List<String> >();
//Loop through assets
for (Asset__c tempasset : [Select Name, Category__c FROM Asset__c WHERE User__c = '0053000000AD9YT'] ) {
List<String> tempassetlist;
//if map already contains category, add to existing list
If (assetmap.containskey(tempasset.Category__c) ){
tempassetlist = assetmap.get(tempasset.Category__c);
}
@britishboyindc
britishboyindc / gist:a9999e87e659612633406d28bd5ab157
Created February 28, 2017 18:27
Apex ZDM Lookup for Contact
//Instantiate Contact and include KW Fields on object
Contact c = new Contact();
//Set Address
c.MailingStreet = '4205 Cordobes Cv';
c.MailingCity = 'San Diego';
c.MailingState = 'CA';
c.MailingPostalCode = '92130';
//KW Fields (populate if already processed contact)
c.kwzd__KW_Error_Code__c = '';
c.kwzd__Latitude__c = NULL;
<apex:page standardController="Opportunity" >
<apex:outputPanel>
<apex:outputText>Thanks!</apex:outputText>
<br/>
<apex:outputField value="{!opportunity.Amount}"/> <br/>
<apex:outputField value="{!opportunity.CloseDate}"/> <br/><br/>
<apex:outputLabel>Household</apex:outputLabel><br/>
<apex:outputField value="{!opportunity.Account.Name}"/><br/>
<br/>