Skip to content

Instantly share code, notes, and snippets.

@joshbirk
joshbirk / gist:a40469fbb81fb65b80c4
Last active June 19, 2016 19:33
Integration FAQ

Salesforce1 Integration FAQ

This FAQ is for people brand new (or returning) to the Salesforce1 Platform and looking to create new integrations.

What’s Salesforce1? Force.com?

We have a broad family of products which each get branded (or at times re-branded) over the years. Salesforce1 refers to the entire family of those products. Force.com refers specificialy to tools on our SaaS cloud (i.e. Apex and Visualforce). Don’t let the branding confuse you, the important parts for integration are:

//Schedulable interface allows for the class to be called on schedule
public with sharing class FlickrHandler implements Schedulable {
//this matches how Flickr JSON is formed
public class FlickrList {
public string title {get; set;}
public string link {get; set;}
public List<FlickrData> items {get; set;}
}
public class SpeedJSONHandler {
public class SpeedList {
List<SpeedData> data;
}
public class SpeedData {
public String TimeStamp {get; set;}
public String Pass {get; set;}
public Decimal Download {get; set;}
//this is a test
var sfStrategy = new ForceDotComStrategy({
clientID: CF_CLIENT_ID,
clientSecret: CF_CLIENT_SECRET,
callbackURL: CF_CALLBACK_URL,
authorizationURL: SF_AUTHORIZE_URL,
tokenURL: SF_TOKEN_URL
//the current sample lists the first param as "Token", but it's really an OAuth object Look at the params field on it.
}, function(oauth, refreshToken, profile, done) {
// asynchronous verification, for effect...
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 ];
<aura:component>
<ui:inputPhone aura:id="phone" label="phone" />
<ui:button label="Show Phone" />
</aura:component>
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');
}
}
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);
}
<script src="https://bit.ly/vf_ios_js"></script>