Apex for Admins: Beyond the Basics
-
Upload
salesforce-developers -
Category
Technology
-
view
106 -
download
0
description
Transcript of Apex for Admins: Beyond the Basics
Apex for Admins Beyond on the Basics!May 29, 2014
#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
David
LiuTechnical Architect, MVP
@dvdkliu
LeeAnne
TemplemanDeveloper Evangelist
@leeanndroid
#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
#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
#forcewebinar
www.SFDC99.com
#forcewebinar
Don’t Miss Out on Dreamforce 2014!
http://bit.ly/df14-apex4admins
$899 Discount Code:
D14DVLPR
#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
#forcewebinar
http://bit.ly/apex4admins-2
#forcewebinar
Recap: SOQL Queries
#forcewebinar
Recap: Trigger Variables
#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
#forcewebinar
Lists
#forcewebinar
Dot Notation
#forcewebinar
Using SOQL with APEX
Where can we do this?
Most important thing we learn!
95% of triggers
Beyond workflow – Cross multiple objects
#forcewebinar
Bind Variable
#forcewebinar
Challenge!
Which of these movies is overrated?
First listener to guess via CHAT wins a Developer Prize Package!
#forcewebinar
Which of these movies is overrated?
#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.
#forcewebinar
Exercise
Let’s write a Deduping Trigger!
#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
#forcewebinar
4 Principles of a Good Test Class
1. Create Records From Scratch
2. Be “Assert”-ive
3. Break Things!
4. Be “Bulky”
#forcewebinar
Principle 1: Create Records From Scratch
#forcewebinar
Principle 2: Be “Assert-ive”
#forcewebinar
Principle 3: Test Things That Should Not Work
#forcewebinar
Principle 4: Be “Bulky”
#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!
#forcewebinar
Other than testing in bulk, which testing principle is this class missing?
Test things That Should Not Work – Negative Testing
#forcewebinar
Exercise!
Let’s write a Test Class for our Deduping Trigger!
#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.
#forcewebinar
What next? Deployment
– Change sets
Visualforce– Upcoming Webinar
Bulkifying– Governor limits
Object Oriented Thinking– Head First Java
#forcewebinar
More SFDC99 Tutorials
Continue with chapters 5 & 6
Chapter quizzes
Get Bulky!
Limits
#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
#forcewebinar
Resources
Developer Forums – http://developer.salesforce.com/forums
SFDC99 – David’s Site
– http://sfdc99.com
Join the community– #Apex4Admins
Q & A
#forcewebinar
David
LiuTechnical Architect, MVP
@dvdkliu
LeeAnne
TemplemanDeveloper Evangelist
@leeanndroid
Survey
Your feedback is crucial to the successof our webinar programs. Thank you!
http://bit.ly.apexbeyondbasics
#forcewebinar