HOT - Introduction to Apex for non-developers

2,879 views
2,591 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,879
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
100
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

HOT - Introduction to Apex for non-developers

  1. 1. Introduction to Apex forNon-Developers Leah McGowen-Hare Senior Technical Instructor, Force.com David Reece Technical Instructor 1
  2. 2. Safe Harbor StatementThis presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. Ifany such uncertainties materialize or if any of the assumptions prove incorrect, the results of salesforce.com, inc.could differ materially from the results expressed or implied by the forward-looking statements we make. Allstatements other than statements of historical fact could be deemed forward-looking statements, including: anyprojections of earnings, revenues, or other financial items; any statements regarding strategies or plans ofmanagement for future operations; any statements concerning new, planned, or upgraded services ordevelopments; statements about current or future economic conditions; and any statements of belief.The risks and uncertainties referred to above include - but are not limited to - risks associated with our newbusiness 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 immature market in which weoperate; our relatively limited operating history; our ability to expand, retain, and motivate our employees andmanage our growth; risks associated with new releases of our service; and risks associated with selling to largerenterprise customers. Further information on potential factors that could affect the financial results ofsalesforce.com, inc. are included in our registration statement (on Form S-1) and in other filings with theSecurities and Exchange Commission. These documents are available on the SEC Filings section of our Website.Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.Any unreleased services or features referenced in this or other press releases or public statements are notcurrently available and may not be delivered on time or at all. Customers who purchase our services should makethe purchase decisions based upon features that are currently available.Training Org Login Org will be active for 30 days post CloudforceUsername: admin@cflon12apex###.comPassword: cf2012 For ###: use the 3-digit number on the cover of your exercise guideExample: Your three digit number = 010 Your username = admin@cflon12apex010.com 2
  3. 3. Agenda What is Apex? Apex Classes Collections Exercise 1: Creating a Class Invoking Apex Apex Triggers Exercise 2: Creating a Trigger Q&AWhat is Apex? Apex is an object-oriented, on-demand programming language. Object-Oriented On-Demand Objects are discrete “bundles”  Functionality that you need, of code modeled after things in when you need it. the real world.  Automatically plugged into other Force.com platform features. 3
  4. 4. When to Use Apex Need a more powerful … … then create an Apex … Validation Rule Trigger Workflow Rule Trigger Sharing/Assignment Rule Trigger Standard Controller Custom Controller Standard Web Service Custom Web Service Email to Case/Lead Email Service Report/Report Type Custom ControllerApex Classes Classes are blueprints used to create objects in code. classesClasses have: Attributes (characteristics). Methods (actions). A unique class name.Classes are represented by a code blocksurrounded by curly braces. 1 public class Human{ 2 // The body of the class 3 } 4
  5. 5. Collections Collections create virtual data structures in memory so that Apex can access records.  Lists are ordered collections of a single datatype.  Each item in a list contains an index and a value. 1 List<DataType> listName = new List<DataType>(); 2 List<Human> cloudforceAttendeess = new List<Human>(); 3 List<Accounts> newAccounts = new List<Accounts>(); Exercise 1:Creating a Hello World Apex Class Hands-on Exercise Task: Create the HelloWorldPositionClass to update the Hello field. For each Position record in input, set Hello__c = ‘World!’ classesHelloWorldPositionClass 5
  6. 6. Invoking Apex classes Creating a job via DML Apex Scheduler OperationsSaving a classes record Invoking an Apex via UI Web Service triggers pages Interacting with a Visualforce page Web Service Client makes a callSaving records anon. via API Sending blocks an email Submitting an anonymous block via API Triggers A trigger is an Apex script that executes before or triggers after a DML operation on a single sObject.  Triggers execute when records are saved through either: – The user interface. – The Web Services API.  Triggers can call classes. 1 trigger triggerName on ObjectName (triggerEvent1, triggerEvent2…) { 2 //code_block 3 } 6
  7. 7. Trigger ContextTrigger context refers to the records that cause a triggerto execute. Trigger.new: a list of the new versions of sObjects Trigger.old: a list of the old versions of sObjectsThese attributes capture the data that’sbeing processed and place it in a listthat you can work with.Exercise 2: Creating a Hello World Apex Trigger Hands-on ExerciseTask:Create the HelloWorldPositionTrigger to call the class. Trigger.new HelloWorldPositionTrigger before insert before update triggers Exercise 1 classes HelloWorldPositionClass 7
  8. 8. Key Takeaways Apex can be used to extend business processes within your Salesforce organization. Classes are like blueprints and have methods and attributes. Triggers execute when records are saved. Apex can access lists of records stored in memory.What’s Next? Ready for more hands-on training? Have Premier? Take a great online class, Follow up with an instructor-led we suggest: course, we suggest: APEX Introduction to Object Oriented Programming Don’t forget.. Visit us in the Tell us what you Cloud Expo for your think with the 10% off training session survey voucher! 8
  9. 9. Question and Answer 9

×