Skip to content

Instantly share code, notes, and snippets.

@joshbirk
joshbirk / 1: Use the Email Interface
Created April 7, 2014 18:45
ELEVATE Extra Credit: Apex Email Services
/* Various features of the Salesforce1 platform require Apex to utilize specific interfaces so the a level of
functionality can be assumed. One of these is the inbound email interface. This allows Apex to be used as an
email service which can process incoming emails.
To complete this extra credit:
1. Create an Apex class that uses the Inbound Email interface using the code below
2. Complete the acceptEmail function so that it returns an email with more information on the product
3. Add the Apex class as an email service and test it manually.
*/
@joshbirk
joshbirk / BlogLog_Services.cls
Created April 29, 2014 18:51
Blog Log CSV Example
global class BlogLog_Services implements Messaging.InboundEmailHandler {
public BlogLog_Services() {}
public Document document {
get {
if (document == null)
document = new Document();
return document;
}
@joshbirk
joshbirk / FlickrHandler.cls
Created August 18, 2014 21:32
FlickrView AKA KittenForce (aka puppyforce)
public with sharing class FlickrHandler {
public class FlickrList {
public string title {get; set;}
public string link {get; set;}
public List<FlickrData> items {get; set;}
}
public class FlickrData {
public string title {get; set;}
@joshbirk
joshbirk / 1. OpportunitiesController.cls
Last active August 29, 2015 14:05
OppHomeComponent
public class OpportunitiesController {
public List<Opportunity> opportunities {get; set;}
public OpportunitiesController() {
opportunities = [SELECT Id, Name, Account.Name, ExpectedRevenue, CloseDate from Opportunity WHERE OwnerId = :UserInfo.getUserId()];
}
}
//NewProj2 isn't a meaningful Apex name. NewProjectTrigger?
trigger NewProj2 on Opportunity (before update) {
for (Opportunity o : Trigger.new)
{
if(o.StageName == 'Closed Won')
{
try
{
SFL5_Projects__c[] proj = [Select Name From SFL5_Projects__c
<script src="https://bit.ly/vf_ios_js"></script>
public class VerifyDate {
//method to handle potential checks against two dates
public static Date CheckDates(Date date1, Date date2) {
//if date2 is within the next 30 days of date1, use date2. Otherwise use the end of the month
if(DateWithin30Days(date1,date2)) {
return date2;
} else {
return SetEndOfMonthDate(date1);
}
trigger RestrictContactByName on Contact (before insert, before update) {
//check contacts prior to insert or update for invalid data
For (Contact c : Trigger.New) {
if(c.LastName == 'INVALIDNAME') { //invalidname is invalid
c.AddError('The Last Name "'+c.LastName+'" is not allowed for DML');
}
}
<aura:component>
<ui:inputPhone aura:id="phone" label="phone" />
<ui:button label="Show Phone" />
</aura:component>
public class DisplayCaseController {
@AuraEnabled
public static Case getCaseFromId(Id caseID) {
if(caseID == null) {
return [SELECT ID, Subject, Description, STATUS from Case LIMIT 1];
}
List<Case> cases = [ SELECT Id, Subject, Description, Status from CASE where ID = :caseID ];