apex for admins: beyond the basics

36
Apex for Admins Beyond on the Basics! May 29, 2014

Upload: salesforce-developers

Post on 26-Jan-2015

107 views

Category:

Technology


0 download

DESCRIPTION

Description Final installation of the 3 part webinar series! Time to use all the Apex skills you have learned in this series and combine SOQL with Apex to build one glorious trigger. This series serves as an Introduction to Apex for Salesforce Administrators with no programming background. This is the last in a 3-part series with David Liu and LeeAnne Templeman. David Liu is the creator of sfdc99.com, an intro to Apex exercise guide for all Salesforce Admins. David is a self-taught Salesforce MVP who began his path as a marketer and is now the Salesforce Technical Architect for Google. He will share some of his own learning path, as well as tips and tricks on how to become a Salesforce developer. Key Takeaways ::Learn the principles of a good test class ::Maintain your data quality by writing a deduping trigger ::Get an outline of the steps to become a Salesforce Developer Series Apex for Admins series: ::Get Started with Apex in 30 Minutes! ::Build on the Basics ::Beyond the Basics ← you are here! Intended Audience ::Salesforce Admins who have begun learning Apex. You should be familiar with basic triggers, Apex classes, and basic Apex. ::Anyone who joined us last week for Apex for Admins: Build on the Basics ::If you missed the previous session, get up to speed with these awesome tutorials from sfdc99.com: Chapter 2: SOQL: A Beginner’s Guide Chapter 3: Core Apex Tools Recommended Resources https://developer.salesforce.com/en/events/webinars/apex-for-admins-beyond-the-basics?d=70130000000hUks

TRANSCRIPT

Page 1: Apex for Admins: Beyond the Basics

Apex for Admins Beyond on the Basics!May 29, 2014

Page 2: Apex for Admins: Beyond the Basics

#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: Apex for Admins: Beyond the Basics

#forcewebinar

Speakers

David

LiuTechnical Architect, MVP

@dvdkliu

LeeAnne

TemplemanDeveloper Evangelist

@leeanndroid

Page 4: Apex for Admins: Beyond the Basics

#forcewebinar

Engage with the Community

@salesforcedevs / #Apex4Admins

Salesforce Developers

Salesforce Developers

The video will be posted to YouTube & the webinar recap page

(same URL as registration).

This webinar is being recorded!Success Community

Page 5: Apex for Admins: Beyond the Basics

#forcewebinar

Have Questions?

Don’t wait until the end to ask your question! – Technical support will answer questions starting now.

Respect Q&A etiquette– Please don’t repeat questions. The support team is

working their way down the queue.

Stick around for live Q&A at the end– Speakers will tackle more questions at the end, time-

allowing.

Head to Developer Forums– More questions? Visit developer.salesforce.com/forums

Page 6: Apex for Admins: Beyond the Basics

#forcewebinar

www.SFDC99.com

Page 7: Apex for Admins: Beyond the Basics

#forcewebinar

Don’t Miss Out on Dreamforce 2014!

http://bit.ly/df14-apex4admins

$899 Discount Code:

D14DVLPR

Page 8: Apex for Admins: Beyond the Basics

#forcewebinar

Introduction to Apex: Beyond the Basics

Last Week Recap

Who should be tuning in?

Lists and Dot Notation

• Combining SOQL and Apex Triggers

• Write your own deduping trigger

• Principles of a good test class

• Learn more about becoming an #AdminWhoCodes

Page 9: Apex for Admins: Beyond the Basics

#forcewebinar

http://bit.ly/apex4admins-2

Page 10: Apex for Admins: Beyond the Basics

#forcewebinar

Recap: SOQL Queries

Page 11: Apex for Admins: Beyond the Basics

#forcewebinar

Recap: Trigger Variables

Page 12: Apex for Admins: Beyond the Basics

#forcewebinar

POP QUIZ!

What type of variable would you need to store this myContact.Account.Owner.Id

Write a query that gets all Opportunities with a close date in the future

What kind of data type is this value? true

SELECT Id FROM Opportunity WHERE CloseDate > TODAY

String

Boolean

Page 13: Apex for Admins: Beyond the Basics

#forcewebinar

Lists

Page 14: Apex for Admins: Beyond the Basics

#forcewebinar

Dot Notation

Page 15: Apex for Admins: Beyond the Basics

#forcewebinar

Using SOQL with APEX

Where can we do this?

Most important thing we learn!

95% of triggers

Beyond workflow – Cross multiple objects

Page 16: Apex for Admins: Beyond the Basics

#forcewebinar

Bind Variable

Page 17: Apex for Admins: Beyond the Basics

#forcewebinar

Challenge!

Which of these movies is overrated?

First listener to guess via CHAT wins a Developer Prize Package!

Page 18: Apex for Admins: Beyond the Basics

#forcewebinar

Which of these movies is overrated?

Page 19: Apex for Admins: Beyond the Basics

#forcewebinar

Deduping Trigger

1. Lead is created or updated

2. Lead has an email address

3. Try to find matching contact based on email address

4. If match is found, populate a Dupe_Contact__c lookup field

5. If match is not found, clear the value of Dupe_Contact__c lookup field.

Page 20: Apex for Admins: Beyond the Basics

#forcewebinar

Exercise

Let’s write a Deduping Trigger!

Page 21: Apex for Admins: Beyond the Basics

#forcewebinar

POP QUIZ!

Without SOQL, what fields are available for each record entering a Trigger?

What character must be placed before every Apex variable used in a SOQL query.

What are the three uses of Dot Notation?

A colon! (:)

Only fields directly on the record are available – related fields are not!

- Access fields- Traverse relationships- Use methods

Page 22: Apex for Admins: Beyond the Basics

#forcewebinar

4 Principles of a Good Test Class

1. Create Records From Scratch

2. Be “Assert”-ive

3. Break Things!

4. Be “Bulky”

Page 23: Apex for Admins: Beyond the Basics

#forcewebinar

Principle 1: Create Records From Scratch

Page 24: Apex for Admins: Beyond the Basics

#forcewebinar

Principle 2: Be “Assert-ive”

Page 25: Apex for Admins: Beyond the Basics

#forcewebinar

Principle 3: Test Things That Should Not Work

Page 26: Apex for Admins: Beyond the Basics

#forcewebinar

Principle 4: Be “Bulky”

Page 27: Apex for Admins: Beyond the Basics

#forcewebinar

SOQL APEX Challenge!

Other than testing in bulk, which testing principle is this class missing?

First listener to guess via CHAT wins a Developer Prize Package!

Page 28: Apex for Admins: Beyond the Basics

#forcewebinar

Other than testing in bulk, which testing principle is this class missing?

Test things That Should Not Work – Negative Testing

Page 29: Apex for Admins: Beyond the Basics

#forcewebinar

Exercise!

Let’s write a Test Class for our Deduping Trigger!

Page 30: Apex for Admins: Beyond the Basics

#forcewebinar

POP QUIZ!

Why shouldn’t a developer query for production records in a Test Class?

Why should every test class use System.assertEquals() even if your code works 100% of the time?Your code may break in the future as your org changes over time. For example, a new validation rule could prevent one of your triggers from updating certain records. System.assertEquals() will alert you of these scenarios before you find out the hard way.

Test code runs without any existing data from both your sandbox and production database! You should always create records from scratch, otherwise you risk test failures down the line.

Page 31: Apex for Admins: Beyond the Basics

#forcewebinar

What next? Deployment

– Change sets

Visualforce– Upcoming Webinar

Bulkifying– Governor limits

Object Oriented Thinking– Head First Java

Page 32: Apex for Admins: Beyond the Basics

#forcewebinar

More SFDC99 Tutorials

Continue with chapters 5 & 6

Chapter quizzes

Get Bulky!

Limits

Page 33: Apex for Admins: Beyond the Basics

#forcewebinar

Recap

• Lists and Dot notation

• Write your own deduping trigger

• Combining SOQL and Apex Triggers

• Principles of a good test class

• What next?

• Becoming an #AdminWhoCodes

Page 34: Apex for Admins: Beyond the Basics

#forcewebinar

Resources

Developer Forums – http://developer.salesforce.com/forums

SFDC99 – David’s Site

– http://sfdc99.com

Join the community– #Apex4Admins

Page 35: Apex for Admins: Beyond the Basics

Q & A

#forcewebinar

David

LiuTechnical Architect, MVP

@dvdkliu

LeeAnne

TemplemanDeveloper Evangelist

@leeanndroid

Page 36: Apex for Admins: Beyond the Basics

Survey

Your feedback is crucial to the successof our webinar programs. Thank you!

http://bit.ly.apexbeyondbasics

#forcewebinar