Alert! Event Notification Options for Force.com Apps Webinar

70
Alert! Event Notication Options for Force.com Apps October 16, 2013

description

Event notification is an important part of most business applications. When something important happens, you sometimes need one or more users to take a specific action. This intermediate- to advanced- level webinar teaches you all about event notification, contrasts the different Salesforce features you can use to implement it, and shows you practical examples of how to use those Salesforce features to suit your specific event notification use case. Key Takeaways :: Understand how use case requirements help you determine the appropriate Force.com feature to use for event notification. :: Implement and contrast event notification with Visualforce pages that poll, Visualforce pages that use the Force.com Streaming API, workflow rules, Chatter feeds and scheduled reports. Intended Audience :: This intermediate-level webinar is geared towards Force.com application developers and architects.

Transcript of Alert! Event Notification Options for Force.com Apps Webinar

Page 1: Alert! Event Notification Options for Force.com Apps Webinar

Alert! Event Noti!cation Options for Force.com Apps October 16, 2013

Page 2: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Safe Harbor

Safe harbor statement under the Private Securities Litigation Reform Act of 1995:

This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services.

The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of intellectual property and other litigation, risks associated with possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-Q for the most recent fiscal quarter ended July 31, 2012. This documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site.

Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.

Page 3: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Speakers

Steve Bobrowski Architect Evangelist @sbob909

Josh Birk Developer Evangelist @JoshBirk

Page 4: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Follow Developer Force for the Latest News

@forcedotcom / #forcewebinar

Developer Force – Force.com Community

+DeveloperForce – Force.com Community

Developer Force

Developer Force Group

Page 5: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Architect Core Resources page

developer.force.com/architect

Page 6: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Have Questions?

§  We have an expert support team at the ready to answer your questions during the webinar.

§  Ask your questions via the GoToWebinar Questions Pane.

§  The speaker(s) will chose top questions to answer live at the end of the webinar.

§  Please post your questions as we go along!

§  Only post your question once; we’ll get to it as we go down the list.

Page 7: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Recognize this scenario in life?

Something happens

Call to action

Someone or thing acts

Page 8: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Recognize this scenario in life?

Leaky pipes

Call plumber

Plumber fixes the pipes

Page 9: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Recognize this scenario in business?

Event Notification Workflow

Page 10: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Recognize this scenario in business?

New Lead created

Salesperson gets alert

Salesperson calls Lead and makes a sale

Page 11: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Optimal event noti!cation design for business apps

Requirements Options

Know your …

Use an option that meets your requirements

Page 12: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Hot, Open Leads Scenario

Requirements §  Notify both online & of"ine

users

§  Notify users immediately

§  Log all alerts

§  Respond to all alerts

Implementation options §  Work"ow rule

§  Chatter feed with email

§  Database trigger with email

Page 13: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Stick around, here’s what you’ll learn …

Requirements

Approaches & implementation options

Demos & source code

Page 14: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Let’s get started …

Page 15: Alert! Event Notification Options for Force.com Apps Webinar

Know your requirements

Page 16: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Event importance can dictate requirements

Critical Insignificant

How important is an event?

Page 17: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Event Noti!cation Requirements: Importance

Requirement Critical Insignificant Minimal Latency Yes No Accountability Yes No Response Yes No

Page 18: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Event frequency can dictate requirements

Frequent Infrequent

How often does an event occur?

Page 19: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Event Noti!cation Requirements: Frequency

Requirement Frequent Infrequent Minimal Latency No Yes Accountability No Yes Response No Yes

Page 20: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Requirements graph example

Requirement Determinant Determinant

Critical Infrequent

Immediate notification

Log

Mandatory response

Page 21: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Requirements example

Requirement Determinant Determinant

Insignificant Frequent

Deferred notification

No log

Optional response

Page 22: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Requirements graph example

Requirement Determinant Determinant

Critical Frequent

Immediate notification

Log

Optional response

Page 23: Alert! Event Notification Options for Force.com Apps Webinar

Know your requirements

Page 24: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Force.com event noti!cation requirements

Determinants •  Importance •  Frequency

Requirements •  Latency •  Accountability •  Resolution

Page 25: Alert! Event Notification Options for Force.com Apps Webinar

Improv + Discovery = Satis!ed Customers How improvistational theatre techniques can improve your discovery skills T.K. Horeis, salesforce.com, Cloud and Industry Architect @TKHoreis Steve Bobrowski, salesforce.com, @sbob909

Page 26: Alert! Event Notification Options for Force.com Apps Webinar

Know your options

Page 27: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Force.com event noti!cation approaches & options

Dynamic Web

pages

Near real-time

messages Deferred

messages

Page 28: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Force.com event noti!cation approaches & options

Dynamic Web

pages

Near real-time

messages Deferred

messages

Page 29: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Dynamic, auto-refreshing Web page

Characteristics §  Teams of users are

online & watching

§  Missed events tolerated

§  Refreshes happen often

§  Receipt of event noti!cation not required

Stock ticker

Page 30: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Dynamic, auto-refreshing Web page

Force.com implementation options Auto-refreshing …

§  Visualforce page

§  Report (browser plugin)

§  List view (browser plugin)

Page 31: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Force.com event noti!cation approaches & options

Dynamic Web

pages

Near real-time

messages Deferred

messages

Page 32: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Near real-time messages

Characteristics §  Users cannot always be online

watching pages

§  Near real-time noti!cation

§  Missed events not tolerable

§  Proof of individual event noti!cation required

§  Relatively few events, low noise Events

Messages

Page 33: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Near real-time messages

Force.com implementation options §  Work"ow rule

–  Email

–  Outbound message

§  Chatter feed with email

§  Chatter feed trigger

Events

Messages

Page 34: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Force.com event noti!cation approaches & options

Dynamic Web

pages

Near real-time

messages Deferred

messages

Page 35: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Deferred messages

Requirements §  Users cannot always be online

watching pages

§  Deferred (signi!cantly) event noti!cations tolerated

§  Missed events tolerable

§  Receipt of individual event noti!cation not required

§  Data set is potentially large

§  Potentially many events

Events

Message

Page 36: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Deferred messages

Force.com implementation options §  Scheduled reports

Events

Message

Page 37: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Force.com event noti!cation approaches & options

Dynamic Web pages •  Visualforce pages •  Reports •  List views

Near real-time messages • Workflow rules •  Chatter feed email •  Chatter feed trigger

Deferred messages •  Scheduled reports

Page 38: Alert! Event Notification Options for Force.com Apps Webinar

Enough theory …

Page 39: Alert! Event Notification Options for Force.com Apps Webinar

Show me how!

Page 40: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Demos: Hot, Open Leads, every which way

Dynamic Visualforce page

Scheduled report

Workflow rule

Page 41: Alert! Event Notification Options for Force.com Apps Webinar

Implementation 1: Dynamic Web page

Visualforce page

Page 42: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

The Observer Pattern: Push vs. Pull

push Lead

Update

pull (polling)

Page 43: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Implementation 1a: Polling with Apex actionPoller

Visualforce page With <apex:actionPoller>

Controller (Apex)

Force.com database

Page 44: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Implementation 1a: Page

<apex:page showHeader=”true" controller=”leadListController" tabstyle="lead" sidebar="false"> <apex:form > <apex:pageBlock > <apex:pageBlockTable id="leadList" value=”{!leads}" var="l"> <apex:column headerValue="Name"> <apex:outputLink value="/{!l.id}">{!l.Name}</apex:outputLink> </apex:column> <apex:column value="{!l.state}"/> <apex:column value="{!l.company}"/> <apex:column value="{!l.email}"/> </apex:pageBlockTable> <apex:actionPoller action=”{!pollAction}" reRender="leadList" interval="15"/> </apex:pageBlock> </apex:form> </apex:page>

Page 45: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Implementation 1a: Controller public with sharing class leadListController { Transient Lead[] leads; String query = 'SELECT Id, Name, State, Company, Email, LastModifiedDate FROM Lead WHERE Status = \'Open - Not Contacted\' AND Rating = \'Hot\' ORDER BY LastModifiedDate DESC LIMIT 100'; public Lead[] getLeads() { leads = Database.query(query); return leads; } public PageReference pollAction() { leads = Database.query(query); return null; }

Page 46: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Traditional polling implementation: Pros & cons

Pros §  Easy

§  Partial page refresh

§  WHERE clause in query

§  Transient controller variable

§  No API calls

Cons §  Wasteful

§  Consumptive

§  View state

Page 47: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Implementation 1b: Streaming API

Visualforce page “subscriber” to the push topic

Push topic

Force.com database

push

Page 48: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Force.com Streaming API factoids

§  Push on CREATE or UPDATE

§  Push topic queries cannot: –  Use relationships (join data)

–  Aggregate data (SUM, AVG, etc.)

–  Reference formula !elds

–  Other limitations

Page 49: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

HOL__c

Implementation 1b: Streaming API

Visualforce page “subscriber” to the push topic

Push topic

trigger Lead

Insert Update Delete

Page 50: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Implementation 1b: Intermediary object

Page 51: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Implementation 1b: Push topic

PushTopic pushTopic = new PushTopic(); pushTopic.Name = 'HOL'; pushTopic.Query = 'SELECT Id, Name, Action__c, Lead_Name__c, Company__c, State__c, Email__c, Lead__c FROM Hot_Open_Lead__c';pushTopic.ApiVersion = 28.0; pushTopic.NotifyForOperations = 'All'; pushTopic.NotifyForFields = 'Referenced'; insert pushTopic;

Page 52: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Implementation 1b: Controller

@RemoteAction static public Lead[] getHotLeads() { String query = 'SELECT Id, Name, State, Company, Email, LastModifiedDate FROM Lead WHERE Status = \'Open - Not Contacted\' AND Rating = \'Hot\' ORDER BY LastModifiedDate DESC'; Lead[] leads = Database.query(query); return leads; }

Page 53: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Implementation 1b: Static Resources

<apex:includeScript value="{!$Resource.cometd}"/> <apex:includeScript value="{!$Resource.jquery}"/> <apex:includeScript value="{!$Resource.json2}"/> <apex:includeScript value="{!$Resource.jquery_cometd}"/> <apex:includeScript value="{!URLFOR($Resource.jquery_ui,'/jquery-ui-1.10.3/ui/jquery-ui.js')}"/> <apex:includeScript value="{!$Resource.underscore}"/>

Page 54: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Implementation 1b: Load Initial Table

var template = $("#holList").html(); leadListController.getHotLeads(function(res,mes) { hotLeads = res; $("#leadTable").html(_.template(template,{items:hotLeads})); });

Page 55: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Implementation 1b: Script Template <tbody>

<% // repeat items _.each(items,function(item){ %> <tr id="lead-<%= item.Id %>" class="dataRow"> <!-- use variables --> <td><a href="/<%= item.Id %>"><%= item.Name %></a></td> <td><%= item.State %></td> <td><%= item.Company %></td> <td><%= item.Email %></td> </tr> <% }); %> </tbody>

Page 56: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Implementation 1b: Respond to Streaming API

// Connect to the CometD endpoint $.cometd.init({ url: window.location.protocol+'//'+window.location.hostname+'/cometd/24.0/', requestHeaders: { Authorization: 'OAuth {!$Api.Session_ID}'} }); // Subscribe to the push topic $.cometd.subscribe('/topic/HOL', function(message) { updateHotLeads(message); });

Page 57: Alert! Event Notification Options for Force.com Apps Webinar

Live demo

Page 58: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Long polling implementation: Pros & cons

Pros §  Minimal page refreshes

§  Partial page refreshes

§  No view state

§  Easy on the database

§  Centralized logic

§  Overcomes Streaming API challenges

Cons §  Requires some code

§  Complex use cases require some thought

Page 59: Alert! Event Notification Options for Force.com Apps Webinar

Implementation 2: Near-real time messaging

Events

Messages

Workflow rule

Page 60: Alert! Event Notification Options for Force.com Apps Webinar

Live demo

Page 61: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Work"ow rule: Pros & cons

Pros §  No code

§  Near real-time messages

§  Accountability (logs)

Cons §  Could get noisy

Page 62: Alert! Event Notification Options for Force.com Apps Webinar

Implementation 3: Deferred messaging

Events

Message

Scheduled report

Page 63: Alert! Event Notification Options for Force.com Apps Webinar

Live demo

Page 64: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Scheduled report: Pros & cons

Pros §  No code

§  No noise

§  Accountability (logs)

Cons

§  Lag time

§  Missed events

Page 65: Alert! Event Notification Options for Force.com Apps Webinar

Summary

Page 66: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Source code

§  Github repo: http://bit.ly/1hR3aMw

Page 67: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Article

Access article link on developer.force.com/architect

Page 68: Alert! Event Notification Options for Force.com Apps Webinar

Even more stuff …

Page 69: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Architect Core Resources page

developer.force.com/architect

Page 70: Alert! Event Notification Options for Force.com Apps Webinar

#forcewebinar

Q & A

Steve Bobrowski Architect Evangelist @sbob909

Josh Birk Developer Evangelist @JoshBirk