Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
The Force.com Coding Tour
Kieren Jameson
Digital Solutions Manager (ETR)
Salesforce MVP
@KierenJameson
WomenCodeHeroes.com...
Safe harbor statement under the Private Securities Litigation Reform Act of 1995:
This presentation may contain forward-lo...
Kieren Jameson Angela Mahoney
@kierenjameson
WomenCodeHeroes.com
RAD Women Co-Founder
ETR Digital Solutions Manager
@iclou...
 You'll understand why you should know what is
going on with code, even if you don't want to
write code yourself.
 You'l...
 Because there are
some things you
can’t do with clicks.
 If you work with
developers, it’s
helpful to know what
they ar...
CLICKS (Declarative)
 Formula Fields
 Validation Rules
 Workflow Rules
 Visual Workflow
 Approval Processes
 Lightni...
1. If you wanted to add a follow-up Task every time a new “hot” Account was
created and assign it to the owner of the Acco...
1. If you wanted to add a follow-up Task every time a new “hot” Account was
created and assign it to the owner of the Acco...
1. If you wanted to add a follow-up Task every time a new “hot” Account was
created and assign it to the owner of the Acco...
1. If you wanted to add a follow-up Task every time a new “hot” Account was
created and assign it to the owner of the Acco...
Basic Apex Building Blocks
 Classes: the "Archetypes"
 Objects: the "Individuals"
 Methods: the "Doers"
 Variables: th...
 Classes are blueprints or templates for
the “stuff” that we’re working with.
 Classes are like Objects in Salesforce
 ...
 Apex objects are like Salesforce records.
 Objects are what we create from classes.
 If a class is a template for an t...
Force.com/Apex Salesforce Examples
Basic Apex
Building Blocks
Class The Architype Salesforce Contact Object
Object The Ind...
 Variables are like luggage…they are reusable
containers to hold things (data)
 They come in different shapes and sizes ...
Force.com/Apex
Data Types
Salesforce Field Type
String Text, Text Areas, Auto Number, Url, Phone, Email
Integer or Decimal...
String firstName = 'Tessa';
String lastName = 'Tourista';
Integer numTours = 0;
Decimal height = 5.4;
Date birthdate = '19...
 Methods are the things
that objects and classes
can do.
 They have a name and can
be passed arguments
(values) that can...
What to wear snorkeling!
+ OR
We have our fins,
snorkel, and mask.
But how do we decide
what else to wear?
Using the method
Defining what the
method does
What to wear snorkeling!
Shorty wetsuit
66-72◦F
What to wear snorkeling!
Over 72◦F
Bathing suit
Full wetsuit
Under 66◦F
Shorty wetsuit
66-72◦F
Full wetsuit
Under 66◦F
What to wear snorkeling!
Over 72◦F
Bathing suit
What should
Tessa wear?
Full wetsuit
Under 66◦F
What to wear snorkeling!
Shorty wetsuit
66-72◦F
Bathing
Suit Time!
Not true
Not true
75◦F
Demo Time: Code in ACTION!!
Photo Source: https://www.flickr.com/photos/raneko/5198682308
Force.com/Apex Salesforce Examples
Basic Apex
Building Blocks
Class The Architype Salesforce Contact Object
Object The Ind...
DML – The “Courier” SOQL– The “Researcher”
Database Manipulation Language
DML pushes record changes to Salesforce
DML
Sale...
DML – The “Courier”
DML is used to send
data to Salesforce
 Insert
 Update
 Upsert
 Delete
 Undelete
DML
DATA PACKAGE...
SOQL – The “Researcher”
SOQL is used to pull data from Salesforce
It can do a LOT, but at minimum, SOQL
has 3 basic pieces...
Demo Time: Code in ACTION!!Photo Source: http://hdwallpapersbase.com/wp-content/uploads/2013/01/Husky-Puppy-Wallpaper1.jpg
Force.com/Apex Salesforce Examples
Basic Apex
Building Blocks
Class The Architype Salesforce Contact Object
Object The Ind...
Photo credit: Melvin Gaal (Mindsharing.eu) / Foter.com
 Triggers kick off code-based
automated processes.
 They listen f...
Trigger Example (avoid double booking)
 We have tours and we have tourists.
 Tourists can only be on one tour at a time....
What does this look like in code?
???
//1. When we try and add or update a tourparticipants__c
record, then before you com...
What does this look like in code?
???
trigger RejectTourDoubleBooking on TourParticipants__c
(before insert, before update...
Demo Time: Code in ACTION!!Photo Source: https://upload.wikimedia.org/wikipedia/commons/f/ff/Cat_on_laptop_-_Just_Browsing...
Force.com/Apex Salesforce Examples
Basic Apex
Building Blocks
Class The Architype Salesforce Account Object
Object The Ind...
More Admins who Code at Dreamforce
Sessions for Beginning Coders
 Intro to Apex for Admins
 Intro to Apex Triggers*
 Fr...
Want to know more?
Salesforce Trailhead
Free online training and tutorials (clicks & code)
bit.ly/sfdc-trailhead
Force.com...
Keep the learning going in the Admin Lodge
Admin Theater
55+ Sessions by Admins for Admins!
Visit Customer-Led Demos Learn...
Share Your Feedback and Win a GoPro
Enroll in a session1 Tap the bell to take a
survey
2 3
Earn a GoPro prize entry
for ea...
Questions?
Kieren Jameson
@kierenjameson
WomenCodeHeroes.com
Angela Mahoney
angela@icloudsalesforce.com
@icoudsf
Thank you
Upcoming SlideShare
Loading in …5
×

The Force.com Coding Tour (Decoding Coding for Awesome Admins)

7,575 views

Published on

Ever felt you needed a decoder ring to understand developer documentation? Are you an admin wanting to understand what ?those Apex coders? are talking about? Want to move from Awesome Admin to Admin who Codes (but need a translator)? You?re in the right place! Join us on a beginner?s guided tour to Apex for Awesome Admins, where we will translate coding concepts into plain English for non-developers and provide real-time demonstrations. Together we?ll explore the wild and wonderful world of Force.com programming, including: the Cavern of Classes, the Ocean of Objects, Method Mountain, the Valley of Variables, the Sea of SOQL, and Trigger Territory. By the end of this session, you?ll understand the basic building blocks of Apex and when (and why) they are used to extend the Salesforce platform.

Published in: Technology
  • Login to see the comments

The Force.com Coding Tour (Decoding Coding for Awesome Admins)

  1. 1. The Force.com Coding Tour Kieren Jameson Digital Solutions Manager (ETR) Salesforce MVP @KierenJameson WomenCodeHeroes.com Decoding Coding for Awesome Admins Angela Mahoney Cat Herder (iCloudSalesforce) Salesforce MVP @icloudsf icloudsalesforce.com
  2. 2. 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 any litigation, risks associated with completed and any 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-K for the most recent fiscal year and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These 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. Safe Harbor
  3. 3. Kieren Jameson Angela Mahoney @kierenjameson WomenCodeHeroes.com RAD Women Co-Founder ETR Digital Solutions Manager @icloudsf icloudsalesforce.com forcelandia.com Portland Developers Group Portland Girly Geeks Group RAD Women Co-Founder FORCE.COM DEVELOPER SALESFORCE ADMINISTRATOR ADVANCED ADMINISTRATOR SALESCLOUD CONSULTANT FORCE.COM DEVELOPER
  4. 4.  You'll understand why you should know what is going on with code, even if you don't want to write code yourself.  You'll understand what your options are for process automation: clicks vs code.  You'll begin to understand the seven basic building blocks of force.com coding.  You'll see some code in action!  You'll get further resources to learn code. What will you walk away with today?
  5. 5.  Because there are some things you can’t do with clicks.  If you work with developers, it’s helpful to know what they are talking about.  Because we’re admins–there's nothing we can’t do! But why is code so hard?  Because developer documentation is very “developer-y” and is sometimes (often!) hard to understand for non-coders.  Because the first (and trickiest) part of learning about code is understanding what the heck the building blocks are and hew they related to what you already know. Why should you care about code? Photo Source: http://bit.ly/1UPStiM
  6. 6. CLICKS (Declarative)  Formula Fields  Validation Rules  Workflow Rules  Visual Workflow  Approval Processes  Lightning Process Builder CODE (Programmatic) Apex Classes & Apex Triggers  If you want to create/update records are not related to the object that you are working with.  Run processes that need a particular order of operation (workflows are triggered randomly).  When you want to create complex business logic that doesn’t require user intervention, including if you have a bunch of workflow rules that run on a single object. When to “Click” and when to “Code”? If you can do it with clicks then generally you should.
  7. 7. 1. If you wanted to add a follow-up Task every time a new “hot” Account was created and assign it to the owner of the Account? Quick Quiz! – Clicks or Code?
  8. 8. 1. If you wanted to add a follow-up Task every time a new “hot” Account was created and assign it to the owner of the Account? CLICKS! Quick Quiz! – Clicks or Code?
  9. 9. 1. If you wanted to add a follow-up Task every time a new “hot” Account was created and assign it to the owner of the Account? CLICKS! 2. If you wanted to add a follow-up Task every time a new “hot” Account was created and assign it to your top Sales Person from the previous FQ? Quick Quiz! – Clicks or Code?
  10. 10. 1. If you wanted to add a follow-up Task every time a new “hot” Account was created and assign it to the owner of the Account? CLICKS! 2. If you wanted to add a follow-up Task every time a new “hot” Account was created and assign it to your top Sales Person from the previous FQ? CODE! Quick Quiz! – Clicks or Code?
  11. 11. Basic Apex Building Blocks  Classes: the "Archetypes"  Objects: the "Individuals"  Methods: the "Doers"  Variables: the "Collectors" Getting Data In & Out of Salesforce  DML: the "Courier"  SOQL: the "Researcher" Putting it all together  Triggers: the "Listeners" What are we decoding today? Force.com Code Tour Itinerary
  12. 12.  Classes are blueprints or templates for the “stuff” that we’re working with.  Classes are like Objects in Salesforce  They know stuff about themselves (these are their variables)  They can do things (these are their methods) Variables First Name, Last Name, Birthday, Age, Record ID, Favorite Pastime, is Tacky?, Annoyance Rating… Classes – the “Architypes” Methods Eat, Drink, Snorkel, Ride Horses, Sightsee, Take Photos, Complain, Talk Loudly, Tip Poorly, Be Annoying …
  13. 13.  Apex objects are like Salesforce records.  Objects are what we create from classes.  If a class is a template for an tourist, then an object is an actual, individual person. Objects – The “Individuals” The Tourista Family! Instances of the Tourist Class (aka Objects) These are objects Photo Credit: http://bit.ly/1JnkRXD Tessa Tourista
  14. 14. Force.com/Apex Salesforce Examples Basic Apex Building Blocks Class The Architype Salesforce Contact Object Object The Individual Individual Contact Record *These are loose translations Your Force.com Decoder Ring
  15. 15.  Variables are like luggage…they are reusable containers to hold things (data)  They come in different shapes and sizes to store different types of things: small, large, and specialty shapes (e.g., hats, golf clubs)  They have a data type, a name, and a value. Variables – The “Collectors” The type of Luggage (e.g., small case) (data type) mySuitcase (variable name) what mySuitcase contains (value) String mySuitcase = 'Full of Stuff'; data type name value
  16. 16. Force.com/Apex Data Types Salesforce Field Type String Text, Text Areas, Auto Number, Url, Phone, Email Integer or Decimal Number, Percent, Currency Boolean Checkbox ID ID of a Salesforce Record Date, DateTime Date, DateTime Your Force.com Field/Data Type Decoder Ring
  17. 17. String firstName = 'Tessa'; String lastName = 'Tourista'; Integer numTours = 0; Decimal height = 5.4; Date birthdate = '1983-02-01'; Boolean isTacky = TRUE; String tipLevel = 'Generous'; ID id = '00300000003S5PGBC0'; Tessa Tourista’s Variables typeOfVariable myContainer = contentsOfContainer; data type name value Photo Credit: http://bit.ly/1JnkRXD Tessa Tourista
  18. 18.  Methods are the things that objects and classes can do.  They have a name and can be passed arguments (values) that can be used inside the method. Methods – The “Doers” Snorkeling Building sand castles Sunbathing Photo source: http://i.huffpost.com/gen/2062638/images/o-TACKY- TOURIST-facebook.jpg
  19. 19. What to wear snorkeling! + OR We have our fins, snorkel, and mask. But how do we decide what else to wear?
  20. 20. Using the method Defining what the method does What to wear snorkeling!
  21. 21. Shorty wetsuit 66-72◦F What to wear snorkeling! Over 72◦F Bathing suit Full wetsuit Under 66◦F
  22. 22. Shorty wetsuit 66-72◦F Full wetsuit Under 66◦F What to wear snorkeling! Over 72◦F Bathing suit What should Tessa wear?
  23. 23. Full wetsuit Under 66◦F What to wear snorkeling! Shorty wetsuit 66-72◦F Bathing Suit Time! Not true Not true 75◦F
  24. 24. Demo Time: Code in ACTION!! Photo Source: https://www.flickr.com/photos/raneko/5198682308
  25. 25. Force.com/Apex Salesforce Examples Basic Apex Building Blocks Class The Architype Salesforce Contact Object Object The Individual Individual Contact Record Variable The Collector Contact Field Method The Do-er Workflow Action* *These are loose translations Your Force.com Decoder Ring
  26. 26. DML – The “Courier” SOQL– The “Researcher” Database Manipulation Language DML pushes record changes to Salesforce DML Salesforce Object Query Language SOQL pulls records from Salesforce SOQL
  27. 27. DML – The “Courier” DML is used to send data to Salesforce  Insert  Update  Upsert  Delete  Undelete DML DATA PACKAGE DML
  28. 28. SOQL – The “Researcher” SOQL is used to pull data from Salesforce It can do a LOT, but at minimum, SOQL has 3 basic pieces:  SELECT – what fields are you want to see  FROM – the Salesforce object that contains these fields  WHERE – any filters on the data SOQL
  29. 29. Demo Time: Code in ACTION!!Photo Source: http://hdwallpapersbase.com/wp-content/uploads/2013/01/Husky-Puppy-Wallpaper1.jpg
  30. 30. Force.com/Apex Salesforce Examples Basic Apex Building Blocks Class The Architype Salesforce Contact Object Object The Individual Individual Contact Record Variable The Collector Contact Field Method The Do-er Workflow Action* Get Data In & Out of Salesforce DML The Courier Save Button* SOQL Query The Researcher Tabular Report* *These are loose translations Your Force.com Decoder Ring
  31. 31. Photo credit: Melvin Gaal (Mindsharing.eu) / Foter.com  Triggers kick off code-based automated processes.  They listen for certain database events (e.g., a record being inserted, updated, etc.).  They either link to or contain the code that makes the magic happen. This lets us do things like…  Compare data before & after a change is made.  Create new, and update existing, related records.  Interact with external data and web services (e.g., external databases & SMS text message services) Triggers– the “Listeners”
  32. 32. Trigger Example (avoid double booking)  We have tours and we have tourists.  Tourists can only be on one tour at a time.  Need something to double-check that we're not double booking tourists. Step 1: Try to add a tourist Contact to a tour. Step 2: Find out what other tours this contact is already booked on. Step 3: Compare the start date of the tours that the person is already on with the start date of the tour we want to add them to. Step 4: If the tour you want to add them to conflicts with the dates of their existing tours, then give an error message and don't let us book the tour. ????
  33. 33. What does this look like in code? ??? //1. When we try and add or update a tourparticipants__c record, then before you commit the data to the database run this trigger. trigger RejectTourDoubleBooking on TourParticipants__c (before insert, before update) { //2. Create a list of all the records (called TPs for "Tour Participants") that we sent to the trigger. Then loop over all these records, and for each one run some code. for (TourParticipants__c TPs : trigger.new) { //3. For each item in the TP list, create another list (called tour) that gets the ID and the start date of the tour we are wanting to add the contact to. Tour__c tour = [SELECT id, startDate__c FROM Tour__c WHERE id = :TPs.tour__c]; //4. Create another list of TourParticipant__c records (called conflicts). Put in this list any records from the TourParticipants__c custom object where the same person we're wanting to add to a tour is already on a tour with the same start date as the tour we are wanting to add them to. list <TourParticipants__c> conflicts = [SELECT id FROM TourParticipants__c WHERE contact__c = :TPs.contact__c AND tour__r.startDate__c = :tour.startDate__c]; //5. If the "conflicts" list is NOT (!) empty, then block the contact from being added to the tour. if (! conflicts.isEmpty() ) { TPs.addError('***DOUBLE BOOKING ERROR***'); } } } WARNING: WE KNOW THIS CODE IS FLAWED
  34. 34. What does this look like in code? ??? trigger RejectTourDoubleBooking on TourParticipants__c (before insert, before update) { for (TourParticipants__c TPs : trigger.new) { Tour__c tour = [SELECT id, startDate__c FROM Tour__c WHERE id = :TPs.tour__c]; list <TourParticipants__c> conflicts = [SELECT id FROM TourParticipants__c WHERE contact__c = :TPs.contact__c AND tour__r.startDate__c = :tour.startDate__c]; if (! conflicts.isEmpty() ) { TPs.addError('***DOUBLE BOOKING ERROR***'); } } } WARNING: WE KNOW THIS CODE IS FLAWED
  35. 35. Demo Time: Code in ACTION!!Photo Source: https://upload.wikimedia.org/wikipedia/commons/f/ff/Cat_on_laptop_-_Just_Browsing.jpg
  36. 36. Force.com/Apex Salesforce Examples Basic Apex Building Blocks Class The Architype Salesforce Account Object Object The Individual Individual Account Record Variable The Collector Account Field Method The Do-er Workflow Action* Get Data In & Out of Salesforce DML The Courier Save Button* SOQL Query The Researcher Tabular Report* Putting it All Together Triggers The Listener Workflow Rule Criteria* *These are loose translations Your Force.com Decoder Ring
  37. 37. More Admins who Code at Dreamforce Sessions for Beginning Coders  Intro to Apex for Admins  Intro to Apex Triggers*  From "Awesome Admin" to "Champion Coder" (How to become a force.com developer)  Triggers for Admins: A Five-step Framework for Creating Triggers  Workflow Formulas as a Gateway to Coding The Dev Zone & Developer Library (Moscone West) Hands-on Trainings  Getting Started with Apex Code for Admins  Getting Started with Visualforce for Admins * Already happened but may have been recorded
  38. 38. Want to know more? Salesforce Trailhead Free online training and tutorials (clicks & code) bit.ly/sfdc-trailhead Force.com Video Training Udacity, Pluralsight bit.ly/apex-video-training RAD Women Learn to code on force.com with other women bit.ly/rad-women Women Code Heroes Helping awesome admins learn to code. Decoder ring included WomenCodeHeroes.com sfdc99.com Apex coding for the 99% sfdc99.com Salesforce Dev Community Tip sheets, workbooks, cookbooks, documentation… developer.salesforce.com
  39. 39. Keep the learning going in the Admin Lodge Admin Theater 55+ Sessions by Admins for Admins! Visit Customer-Led Demos Learn more with Trailhead! Earn your Apex Basics & Database badge
  40. 40. Share Your Feedback and Win a GoPro Enroll in a session1 Tap the bell to take a survey 2 3 Earn a GoPro prize entry for each completed survey
  41. 41. Questions? Kieren Jameson @kierenjameson WomenCodeHeroes.com Angela Mahoney angela@icloudsalesforce.com @icoudsf
  42. 42. Thank you

×