Alert! Event Notification Options for Force.com Apps Webinar

Post on 15-Jan-2015

1.710 views 0 download

Tags:

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

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

#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.

#forcewebinar

Speakers

Steve Bobrowski Architect Evangelist @sbob909

Josh Birk Developer Evangelist @JoshBirk

#forcewebinar

Follow Developer Force for the Latest News

@forcedotcom / #forcewebinar

Developer Force – Force.com Community

+DeveloperForce – Force.com Community

Developer Force

Developer Force Group

#forcewebinar

Architect Core Resources page

developer.force.com/architect

#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.

#forcewebinar

Recognize this scenario in life?

Something happens

Call to action

Someone or thing acts

#forcewebinar

Recognize this scenario in life?

Leaky pipes

Call plumber

Plumber fixes the pipes

#forcewebinar

Recognize this scenario in business?

Event Notification Workflow

#forcewebinar

Recognize this scenario in business?

New Lead created

Salesperson gets alert

Salesperson calls Lead and makes a sale

#forcewebinar

Optimal event noti!cation design for business apps

Requirements Options

Know your …

Use an option that meets your requirements

#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

#forcewebinar

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

Requirements

Approaches & implementation options

Demos & source code

#forcewebinar

Let’s get started …

Know your requirements

#forcewebinar

Event importance can dictate requirements

Critical Insignificant

How important is an event?

#forcewebinar

Event Noti!cation Requirements: Importance

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

#forcewebinar

Event frequency can dictate requirements

Frequent Infrequent

How often does an event occur?

#forcewebinar

Event Noti!cation Requirements: Frequency

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

#forcewebinar

Requirements graph example

Requirement Determinant Determinant

Critical Infrequent

Immediate notification

Log

Mandatory response

#forcewebinar

Requirements example

Requirement Determinant Determinant

Insignificant Frequent

Deferred notification

No log

Optional response

#forcewebinar

Requirements graph example

Requirement Determinant Determinant

Critical Frequent

Immediate notification

Log

Optional response

Know your requirements

#forcewebinar

Force.com event noti!cation requirements

Determinants •  Importance •  Frequency

Requirements •  Latency •  Accountability •  Resolution

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

Know your options

#forcewebinar

Force.com event noti!cation approaches & options

Dynamic Web

pages

Near real-time

messages Deferred

messages

#forcewebinar

Force.com event noti!cation approaches & options

Dynamic Web

pages

Near real-time

messages Deferred

messages

#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

#forcewebinar

Dynamic, auto-refreshing Web page

Force.com implementation options Auto-refreshing …

§  Visualforce page

§  Report (browser plugin)

§  List view (browser plugin)

#forcewebinar

Force.com event noti!cation approaches & options

Dynamic Web

pages

Near real-time

messages Deferred

messages

#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

#forcewebinar

Near real-time messages

Force.com implementation options §  Work"ow rule

–  Email

–  Outbound message

§  Chatter feed with email

§  Chatter feed trigger

Events

Messages

#forcewebinar

Force.com event noti!cation approaches & options

Dynamic Web

pages

Near real-time

messages Deferred

messages

#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

#forcewebinar

Deferred messages

Force.com implementation options §  Scheduled reports

Events

Message

#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

Enough theory …

Show me how!

#forcewebinar

Demos: Hot, Open Leads, every which way

Dynamic Visualforce page

Scheduled report

Workflow rule

Implementation 1: Dynamic Web page

Visualforce page

#forcewebinar

The Observer Pattern: Push vs. Pull

push Lead

Update

pull (polling)

#forcewebinar

Implementation 1a: Polling with Apex actionPoller

Visualforce page With <apex:actionPoller>

Controller (Apex)

Force.com database

#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>

#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; }

#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

#forcewebinar

Implementation 1b: Streaming API

Visualforce page “subscriber” to the push topic

Push topic

Force.com database

push

#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

#forcewebinar

HOL__c

Implementation 1b: Streaming API

Visualforce page “subscriber” to the push topic

Push topic

trigger Lead

Insert Update Delete

#forcewebinar

Implementation 1b: Intermediary object

#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;

#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; }

#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}"/>

#forcewebinar

Implementation 1b: Load Initial Table

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

#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>

#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); });

Live demo

#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

Implementation 2: Near-real time messaging

Events

Messages

Workflow rule

Live demo

#forcewebinar

Work"ow rule: Pros & cons

Pros §  No code

§  Near real-time messages

§  Accountability (logs)

Cons §  Could get noisy

Implementation 3: Deferred messaging

Events

Message

Scheduled report

Live demo

#forcewebinar

Scheduled report: Pros & cons

Pros §  No code

§  No noise

§  Accountability (logs)

Cons

§  Lag time

§  Missed events

Summary

#forcewebinar

Source code

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

#forcewebinar

Article

Access article link on developer.force.com/architect

Even more stuff …

#forcewebinar

Architect Core Resources page

developer.force.com/architect

#forcewebinar

Q & A

Steve Bobrowski Architect Evangelist @sbob909

Josh Birk Developer Evangelist @JoshBirk