51
Coding The Cloud with Apex and Visualforce Programmatic Elevate Workshop Samantha Ready - Developer Evangelist @samantha_ready [email protected] Dave Carroll – Developer Evangelist @dcarroll [email protected]

Elevate Tel Aviv

  • Upload
    sready

  • View
    267

  • Download
    3

Embed Size (px)

DESCRIPTION

This is the deck for the programmatic track of Elevate. Elevate is a hands-on, one day training teaching new developers about foundational programmatic features of the Salesforce1 Platform.

Citation preview

Page 1: Elevate Tel Aviv

Coding The Cloud with Apex and VisualforceProgrammatic Elevate Workshop

Samantha Ready - Developer Evangelist@[email protected]

Dave Carroll – Developer Evangelist@[email protected]

Page 2: Elevate Tel Aviv

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: Elevate Tel Aviv

Welcome!

WIFI Connection

SSID: Elevate

PWD: salesforce1

Page 4: Elevate Tel Aviv

What we want to accomplish today

Jumpstart Programmatic Development on Force.com

Learn how to use the Apex Language

Understand how to use Visualforce for Salesforce1

Experience coding the cloud

Enjoy ourselves in the process

Page 5: Elevate Tel Aviv

What should know already

Some exposure to Salesforce1 Platform– Beginner workshop is a great preparation

(but not required)

Programming experience in another language– .Net or Java or Ruby or Javascript (but not

required)

Web programming experience– HTML and CSS (but not required)

Page 6: Elevate Tel Aviv

The Salesforce1 Customer Platform

Salesforce1 Platform APIs

Salesforce1 App

Salesforce1 Platform Services

Force.com HerokuExactTarget

Fuel

Page 7: Elevate Tel Aviv

Over 1.5 Million Registered Developers

Page 8: Elevate Tel Aviv

102 Developer User Groups

Page 9: Elevate Tel Aviv

Salesforce1 Platform

Salesforce is a Platform Company. Period.-Alex Williams, TechCrunch

1BAPI Calls Per Day

6BLines of Apex

4M+Apps Built on the Platform

1T+Records Processed per Month

Page 10: Elevate Tel Aviv

Consider Becoming a Certified Developer

Page 11: Elevate Tel Aviv

Brief Overview of the App So Far

Warehousing app– Tracks inventory

– Checks for valid data

– Stores delivery info

That’s the data model there >>

Page 12: Elevate Tel Aviv

Missed the beginner track?

Demo on Data Modeling

Page 13: Elevate Tel Aviv

Workbook Preparation – Let’s do this together!

Start with a new Developer Edition

Install Warehouse Sample Application

Try out the Salesforce1 Browser App

Install the Salesforce1 Mobile App– Search Salesforce1 in Apple App Store or in Google Play

Store

Tutorial 1

Page 14: Elevate Tel Aviv

Developer Basics – Tools of the Trade

Built in Editors

Developer Console

Eclipse Plugin

Command Line Interface

Workbench

Third Party Tools

Page 15: Elevate Tel Aviv

Developer Console Tour

Tutorial 2

Page 16: Elevate Tel Aviv

Apex Language Orientation

It’s like Java or .Net– Strongly typed with curly braces

Common primitive data types

Familiar collections and logic constructs

Classes and Interfaces and Inheritance

Familiar polymorphic exception handling

Page 17: Elevate Tel Aviv

This is what it looks like

Page 18: Elevate Tel Aviv

Invoking Apex Code

Can be executed directly– Execute Anonymous

Can be triggered by database changes– Insert, Update, Delete, before and after triggers

Can be directly called through REST– Custom Apex Rest Service

Invoked as the controller portion of a Visualforce page

Page 19: Elevate Tel Aviv

Apex Has Data Manipulation Built In

Query is first class part of the language– [Select Id, Name From Account Where Country = ‘UK’]

Insert, update, delete and upsert

Full database transaction control– SetSavePoint and Rollback

Operates on sets of or single sObjects

Page 20: Elevate Tel Aviv

Retrieving Data Using SOQL and SOSL

SOQL is like SQL, only one verb supported (select)– Aggregation, grouping, and geolocation are all

supported

– Relationship navigation, sub queries and anti joins are supported

SOSL is for searching for data across columns and tables– Full text search and polymorphic results across objects

– Supports abstract search field specification• Find “5559993344” in Phone Fields

Page 21: Elevate Tel Aviv

What is an sObject?

It is a chunk of data, a kin to a record, but more– An sObject can contain a sef of other sObjects (child

records)

– All stored data is represented as an sObject

– They all have a universally unique Id (kind of like a foreign key)

Automatically available through a REST endpoint

Can have computed fields (we call them formula fields)

Page 22: Elevate Tel Aviv

Working with sObjects

DML Demo

Page 23: Elevate Tel Aviv

Implementing Triggers

Excellent choice to enforce business logic– Triggers fire no matter what caused the data change

Triggers operate in bulk– You should assume that more than one record is part of

the execution scope

Consider the use of Asynchronous options– Calling out to a web service, cascading changes to

many different objects

Page 24: Elevate Tel Aviv

Implementing Triggers

Let’s look at some triggers…

Page 25: Elevate Tel Aviv

Implementing Triggers

Trigger Tutorial

Workbook: http://bit.ly/telaviv_guide

Page 26: Elevate Tel Aviv

Unit Testing in Apex

Built in support for testing– Test Utility Class Annotation

– Test Method Annotation

– Test Data build up and tear down

Unit test coverage is required– Must have at least 75% of code covered

Why is it required?

Page 27: Elevate Tel Aviv

Implementing Unit Tests

Unit Test Demo

Page 28: Elevate Tel Aviv

Implementing Unit Tests

Unit Test Tutorial

Page 29: Elevate Tel Aviv

Apex Batch Processing

Governor Limits– Various limitations around resource usage

Asynchronous processing– Send your job to a queue and we promise to run it

Can be scheduled to run later– Kind of like a chron job

Page 30: Elevate Tel Aviv

Implementing Apex Batch Processing

Apex Batch Processing Tutorial

Page 31: Elevate Tel Aviv

Writing Your Own REST Service with Apex

Aggregating DML– Most REST services are very granular

Implementing database transactions in REST– Enforce you business logic at the data layer

Common “servlet” model– Annotations to specify POST, GET, PATCH, DELETE

You control the URL Mapping for the resource

Page 32: Elevate Tel Aviv

Implementing Apex Rest Services

Apex Rest Services Tutorial

Page 33: Elevate Tel Aviv

Let’s Take a Break!

Lunch Break

Page 34: Elevate Tel Aviv

What can you do with Visualforce?

Framework to build custom user interfaces

Hosted natively on Force.com

Build streamlined UX

Create internal and public facing pages

Customize for different devices

Leverage other web technologies

Page 35: Elevate Tel Aviv

Model View Controller (MVC) PatternStandard and

Custom ObjectsStandard

Controllers and Apex

Visualforce

Page 36: Elevate Tel Aviv

Mobile Visualforce in Salesforce1

Where can I put Visualforce Pages?– Navigation Menu

– Publisher

– Record Homepage – Mobile Cards

Build UI with ‘Mobile Ready’ techniques (responsive, CSS, etc)

Navigation: sforce.one object– Ex: sforce.one.navigateToRelatedList(relatedListId,

parentRecordId)

Page 37: Elevate Tel Aviv

The Salesforce1 App

All your past investments...

Drag and drop UI customization

Notifications Platform

Publisher Actions

...now in the future

Download Salesforce1 App today

All Your Customization

s

All Your Devices

All Your CRM

All Your Apps

https://yourinstance.salesforce.com/one/one.app

Page 38: Elevate Tel Aviv

Adding Visualforce to Global Navigation

Responsive VF Page

in Left Nav Demo

Page 39: Elevate Tel Aviv

Visualforce – Left Nav

Visualforce tabs in Mobile

Navigationsforce.one object for

navigation

Page 40: Elevate Tel Aviv

Adding Visualforce to Global Navigation

Global Navigation Tutorial

Page 41: Elevate Tel Aviv

Adding Visualforce to Global Navigation

Directions & Check In

App Demo

Page 42: Elevate Tel Aviv

Visualforce – Publisher Actions

Visualforce Pages as Publisher Actions

(Object Specific vs Global)

JavaScript Pub-Sub library available to interact with the publisher

publisher.setValidForSubmit

publisher.post

publisher.close

Page 43: Elevate Tel Aviv

Visualforce – Mobile Cards

Mobile Cards - Visualforce Pages on

Record Detail(VF page needs to the extend

Standard Controller)

Page 44: Elevate Tel Aviv

Visualforce in Salesforce1

<apex:page docType="html-5.0" …>

‘Available for Salesforce Mobile apps’ flag enabled

Developers are responsible for making the VF page ‘mobile ready’

• Use a Responsive Design framework like Bootstrap or Mobile Design templates

• Leverage touch and swipe events where appropriate

Use JavaScript Remoting/VF Remote Objects for better performance

Use HTML5 for device features like Geolocation and Camera access

Page 45: Elevate Tel Aviv

Visualforce Mobile Cards and Actions in Salesforce1

Mobile Card &

Publisher Action

Tutorial

Page 46: Elevate Tel Aviv

Salesforce Canvas Overview

Enable integration of external applications securely within Salesforce1 from the native environment– Javascript API, Secure Authentication, Context Services,

X-Domain API, Eventing Model, App Registration and Management

Page 47: Elevate Tel Aviv

When might you use Canvas?

Your data does not reside in salesforce.com– The data is best consumed in the context of salesforce,

but is not required to reside there

You have developers focused on other technologies– Sometimes Salesforce1 developers are hard to find

You have an existing application– Don’t need to reinvent the wheel

Page 48: Elevate Tel Aviv

Using Canvas in Salesforce 1

Canvas Tutorial

Page 49: Elevate Tel Aviv

Useful Resources

Join a Developer User Group– http://bit.ly/fdc-dugs

– Birmingham West Midlands - bit.ly/birminghamdug

– London – bit.ly/londondug

– Bristol – bit.ly/bristoldug

– Dublin – bit.ly/dublindug

Become a Developer User Group Leader– Email: April Nassi [email protected]

Page 50: Elevate Tel Aviv

Developer Force – Resources and More

Page 51: Elevate Tel Aviv

Thank You