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
2. #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.
4. #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
5. #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
8. #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
12. #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
15. #forcewebinar
Using SOQL with APEX
Where can we do this?
Most important thing we
learn!
95% of triggers
Beyond workflow
– Cross multiple objects
19. #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.
21. #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
22. #forcewebinar
4 Principles of a Good Test Class
1. Create Records From Scratch
2. Be “Assert”-ive
3. Break Things!
4. Be “Bulky”
27. #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!
28. #forcewebinar
Other than testing in bulk, which testing principle is this class
missing?
Test things That Should Not Work – Negative Testing
30. #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.
31. #forcewebinar
What next?
Deployment
– Change sets
Visualforce
– Upcoming Webinar
Bulkifying
– Governor limits
Object Oriented Thinking
– Head First Java
33. #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