SlideShare ist ein Scribd-Unternehmen logo
1 von 31
Coding the Cloud: An Introduction
to Apex Code

       Force.com Platform Fundamentals


                     Andrew Albert, salesforce.com
Safe Harbor Statement
“Safe harbor” statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-
looking statements including but not limited to statements concerning the potential market for our existing service offerings
and future offerings. All of our forward looking statements involve risks, uncertainties and assumptions. If any such risks or
uncertainties materialize or if any of the assumptions proves incorrect, our results could differ materially from the results
expressed or implied by the forward-looking statements we make.

The risks and uncertainties referred to above include - but are not limited to - risks associated with possible fluctuations in
our operating results and cash flows, rate of growth and anticipated revenue run rate, errors, interruptions or delays in our
service or our Web hosting, our new business model, our history of operating losses, the possibility that we will not remain
profitable, breach of our security measures, the emerging market in which we operate, our relatively limited operating
history, our ability to hire, retain and motivate our employees and manage our growth, competition, our ability to continue to
release and gain customer acceptance of new and improved versions of our service, customer and partner acceptance of
the AppExchange, successful customer deployment and utilization of our services, unanticipated changes in our effective
tax rate, fluctuations in the number of shares outstanding, the price of such shares, foreign currency exchange rates and
interest rates.

Further information on these and other factors that could affect our financial results is included in the reports on Forms 10-
K, 10-Q and 8-K and in other filings we make with the Securities and Exchange Commission from time to time. These
documents are available on the SEC Filings section of the Investor Information section of our website at
www.salesforce.com/investor. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-
looking statements, except as required by law.
Andrew Albert
Technical Evangelist
Apex Code: Logic-as-a-Service

                             What is it?


                             What can it do?


                             How do I use it?


                             Well, let‟s see it!
Introducing Apex
  Force.com allows many customizations through User
   Interface
  Force.com API allows developers to write client-side
   programs or integrations for more flexibility in their
   applications
    – Client side programs have performance costs
    – Lack transactional control across API requests
    – Cost and complexity of client hosting server code
  APEX was introduced to address those issues and to
   revolutionize the way developers create on-demand
   applications.
Apex Code Is
 Strongly-typed, object-based programming language
 Enables developers to execute logic and transaction
  control statements on Force.com
 Runs natively on the server
 Code executes on the server when initiated by User
  Interface via Buttons & Events, and data through the
  API
 Java or C#-like syntax
 Transactional
How can you use Apex Code?
 Database Trigger
   - Apex Code that is executed in response to a
     database interaction


     Example: Apex trigger is initiated whenever a new
     Contact record is inserted.


 Class
   - Similar to a Java or .NET class
   - A trigger can call an Apex Class
Differences between Triggers and Classes
  Triggers execute implicitly in response to a database
   action
  Apex class methods can be explicitly called in many
   areas of the Force.com


  For example:
    (a) Email to Apex Services
    (b) Apex Web Services
    (c) Visualforce controllers
How is Apex Different?
  Executes directly on the Force.com
  Eliminates network traffic between client application
   and Force.com
  Apex Code tightly integrated to the rest of the platform
   functionality
  Changes to the metadata referenced in Apex Code will
   cause an automatic recompilation the next time those
   components are executed
Language Basics
Data Types – Primitive
   -   String
   -   Boolean
   -   Date and DateTime
   -   Integer, Long, Double
   -   ID (Force.com database record identifier)
   -   Blob (for storing binary data)
   -   Sobject (object representing a Force.com standard or custom
       object)
   Example:
       DateTime dt = System.now() + 1;
       Boolean isClosed = true;
       String sCapsFirstName = „Andrew‟.toUpperCase();
       Account acct = new Account(); //Sobject example
Language Basics (cont)
 Data Types – Collections
    -   Lists
    -   Sets
    -   Maps
    -   Arrays


    Example:
         List<Integer> myList = new List<Integer>();
         myList.add(12); //Add the number 12 to the list
         myList.get(0); //Access to first integer stored in the List
Language Basics (cont)
 Statements and Expressions
    - If/Else
    - For Loops
    - Do/While Loops
    - While Loops

    Example:
       Integer count = 0;
       while(count < 11){
            System.debug(„Count = „ + count);
            count++;
       }
Language Basics (cont)
 Exception Handling
    - Try/Catch/Finally statements
    - Ability to create and throw your own Exceptions

    Example:
       public class OtherException extends BaseException {}
       Try{
           //Add code here
           throw new OtherException(„Something went wrong here…‟);
       } Catch (OtherException oex) {
           //Caught a custom exception type here
       } Catch (Exception ex){
           //Caught all other exceptions here
       }
Force.com Query Languages
 SOQL – Salesforce object Query Language
   String myName = „Acme‟;
        Account[] accts = [select ID from Account where name =:myName] //Pass in a variable


 SOSL – Salesforce object Search Language
   List<List<SObject>> searchList = [FIND '415' IN PHONE FIELDS RETURNING Account, Contact ];
   Account [] accounts = ((List<Account>)searchList[0]);
   Contact [] contacts = ((List<Contact>)searchList[1]);
Data Manipulation with Apex
  DML (Data Manipulation Language)
    -   Insert
    -   Update
    -   Upsert - Operation to create a new or update existing record
        based on an external id.
    -   Delete
    -   Undelete
Here’s what it looks like                                                  Interface
                                                                        Implementation
                                                                                                     Function
                                                                                                    Declaration
 1 1 global class tasks implements Messaging.InboundEmailHandler {
 2 2
 3 3 global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email,
 4 4                                 Messaging.InboundEnvelope env){
 5 5
 6 6 // Create inboundEmailResult object for returning the result of the Force.com Email Service
 7 7 Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
 8 8
 9 9 String myPlainText = '‟;                                                                         Object
 101                                                                                               Instantiation
                                                    Variable Declaration
 111 // Add the email plain text into the local variable
 121 try {
 131      myPlainText = email.plainTextBody.substring(0, email.plainTextBody.indexOf('<stop>'));
 141 } catch (System.StringException e) {
 151      myPlainText = email.plainTextBody;                                           Exception
 161      System.debug('No <stop> in email: ' + e);                                     Handling
 171 }
 181
 191 // new Task object to be created                                    List Creation                   Comment
 202 List<Task> newTask = new List<Task>();                                                               Syntax
 212
 222 /* Try to lookup any contacts based on the email from address
 232 / If there is more than 1 contact with the same email address
 24      / an exception will be thrown and the catch statement will be called
 25     */
 262 try {
 272       Contact vCon = Id, Name, Email From Contact Where Email = :email.fromAddress]
                    [Select
 28
 29                  ...
                                                                               Query Language
Bulk data operations with Apex
  Commonly, the ordering of process for an apex solution is as follows:
     1)   Records are retrieved from the Force.com database with a query
          statement
     2)   The array of records ismodified in the processing of your Apex
          Code
     3)   The array of records is then sent back to the object through a
          data manipulation statement




          These actions are performed in bulk on the Force.com
Bulk data operations with Apex (cont)

  Apex Code must be designed to handle bulk operations
  Why is this important?
     -   The Force.com enforces limits to how many records can be
         processed at a time (governor limits)
  Examples:
      Limit on the number of records that can be queried.
      Limit on the number of records that be modified.
  Limits are calculated by the number of records invoking the Apex
   Code code
Handling Bulk operations - example
Testing

 Apex Code to test your Apex Code
 Code to help developers perform and automate unit testing
 Enables the platform to execute these “test methods” during
  deployment
 Force.com requires that at least 75% of your Apex is
  covered by testing before code can be deployed to a
  Production environment (100% is ideal!)
 Unit test methods are denoted with testMethod keyword.
 testMethods do not modify any data in your org
What can you do with Apex Code?
 Triggers
 Apex Web Services
 Email Services
 SOA (callouts)
 Visualforce Controllers
What can you do with Apex Code?
  Triggers
    – Code runs when data changes to ensure business logic is
      applied
    – Executes on the server when data changes in either the UI or API.



  Email Services
    – Send & Receive emails, including attachments, with custom
      logic to process contents.
    – Includes all standard email attributes, use email templates, and
      supports plain text or HTML.
    – Force.com generates a unique email address to process the
      contents.
What else can you do with Apex Code?
  Apex Web Services
   – Develop new Force.com Web Services
   – Define and expose a custom Web Service for an external service
     to invoke.
   – As simple as adding the “webService” keyword to a Apex method
   – WSDL automatically available

  Consume other Web Services
   – Provides integration with external Web Services
   – Apex provides integration with Web services that utilize SOAP
     and WSDL, or HTTP services
What else can you do with Apex Code?
 Visualforce Controllers
   – Apex logic accessed by Visualforce pages through custom
     controllers and controller extensions.
   – Apex Class that drives the logic when a user interacts with the
     Visualforce pages.
Winter ‘09 Apex Feature – Dynamic Apex

                                                                  Streamline code design
public class displayFields{
……
//Retrieves available SObjects with Global Describe
                                                                   eliminate repetitive code by
private Map <String, Schema.SObjectType> schemaMap =
Schema.getGlobalDescribe();                                        constructing dynamic procedures
//Retrieve accessible fields for specified object
public List<Field> showFields(String selectedObject) {
                                                                   for query, search, and data
fields.clear();
Map <String, Schema.SObjectField> fieldMap =                       manipulation
schemaMap.get(selectedObject).getDescribe().fields.getMap();
//for each field – determine whether the running user has
access to the field
                                                                  Describe methods
    for(Schema.SObjectField f : fieldMap.Values()){
        Schema.DescribeFieldResult df = f.getDescribe();
        if(df.isAccessible()){
                                                                   New Apex methods to describe
             fields.add(f);
        }                                                          schema including object definition
    }
return fields;                                                     and field definitions.
}

                                                                  User permission awareness
                                                                   The power of system level access
                                                                   with the capability to enforce user
                                                                   permissions and constraints
Winter ‘09 Apex Feature – Async Apex

global class myclass {
    public class MyException extends Exception{}
                                                      Asynchronous execution
    public static void throwException() {
      System.debug('calling throw exception');        Supports web service callouts
      throw new MyException('for bar');
    }                                                  from triggers
  @future(callout=true) static void voidvoid() {
     System.debug('void void');                       Monitoring UI provides
     Http http = new Http();
     HttpRequest req = new HttpRequest();              detailed view of status and
     req.setMethod('GET');
     req.setEndpoint('http://www.cheenath.com');       execution time
     HttpResponse res = http.send(req);
     System.debug(res.getBody());
     //throw new MyException('for bar');
  }
  @future static void createAccount(String n) {
     Account a = new Account(name=n);
     insert a;
  }
Additional Dreamforce 2008 Apex Sessions

 Apex Test Coverage Best Practices
   – Tuesday, 2:00-3:00PM, Esplanade 305
 Hands-On : Apex Code
   – Tuesday, 2:00-3:00PM, South 102
 Development As A Service – Building and Deploying Apps
  in the Cloud
   – Wednesday, 10:15-11:15AM, Esplanade 303
Force.com Library
 Books
  – Developer‟s Guide to the Force.com
  – Force.com Cookbook
  – Creating On-Demand Apps
 Apex Language Reference
Additional Resources
  Developer.Force.com
    – Force.com Developer Community
    – Apex Developer Guide & Language Reference
    – Recorded technical presentations and whitepapers
    – Apex Message Boards

   Sign up for free Developer Edition
   Training Courses & Certification
     – DEV401: Force.com essentials
     – DEV501: Visualforce, Apex, DaaS (Development As A Service)
Session Feedback
Let us know how we’re doing and enter to win an iPod nano!
    Please score the session from 5 to 1 (5=excellent,1=needs
       improvement) in the following categories:
         Overall rating of the session
         Quality of content
         Strength of presentation delivery
         Relevance of the session to your organization


               Additionally, please fill in the name of each speaker &
               score them on overall delivery.


                We strive to improve, thank you for filling out our survey.
QUESTION & ANSWER
     SESSION

Weitere ähnliche Inhalte

Was ist angesagt?

Salesforce Development Best Practices
Salesforce Development Best PracticesSalesforce Development Best Practices
Salesforce Development Best PracticesVivek Chawla
 
Best Practices with Apex in 2022.pdf
Best Practices with Apex in 2022.pdfBest Practices with Apex in 2022.pdf
Best Practices with Apex in 2022.pdfMohith Shrivastava
 
Salesforce Basic Development
Salesforce Basic DevelopmentSalesforce Basic Development
Salesforce Basic DevelopmentNaveen Dhanaraj
 
Lightning web components episode 2- work with salesforce data
Lightning web components   episode 2- work with salesforce dataLightning web components   episode 2- work with salesforce data
Lightning web components episode 2- work with salesforce dataSalesforce Developers
 
Introduction to the Salesforce Security Model
Introduction to the Salesforce Security ModelIntroduction to the Salesforce Security Model
Introduction to the Salesforce Security ModelSalesforce Developers
 
Maximizing Salesforce Lightning Experience and Lightning Component Performance
Maximizing Salesforce Lightning Experience and Lightning Component PerformanceMaximizing Salesforce Lightning Experience and Lightning Component Performance
Maximizing Salesforce Lightning Experience and Lightning Component PerformanceSalesforce Developers
 
Build Reliable Asynchronous Code with Queueable Apex
Build Reliable Asynchronous Code with Queueable ApexBuild Reliable Asynchronous Code with Queueable Apex
Build Reliable Asynchronous Code with Queueable ApexSalesforce Developers
 
Salesforce Application Lifecycle Management presented to EA Forum by Sam Garf...
Salesforce Application Lifecycle Management presented to EA Forum by Sam Garf...Salesforce Application Lifecycle Management presented to EA Forum by Sam Garf...
Salesforce Application Lifecycle Management presented to EA Forum by Sam Garf...Sam Garforth
 
Real Time Integration with Salesforce Platform Events
Real Time Integration with Salesforce Platform EventsReal Time Integration with Salesforce Platform Events
Real Time Integration with Salesforce Platform EventsSalesforce Developers
 
All About Test Class in #Salesforce
All About Test Class in #SalesforceAll About Test Class in #Salesforce
All About Test Class in #SalesforceAmit Singh
 
Lightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An IntroductionLightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An IntroductionSalesforce Developers
 
Salesforce Release Management - Best Practices and Tools for Deployment
Salesforce Release Management - Best Practices and Tools for DeploymentSalesforce Release Management - Best Practices and Tools for Deployment
Salesforce Release Management - Best Practices and Tools for DeploymentSalesforce Developers
 
Batch Apex in Salesforce
Batch Apex in SalesforceBatch Apex in Salesforce
Batch Apex in SalesforceDavid Helgerson
 
Apex Trigger in Salesforce
Apex Trigger in SalesforceApex Trigger in Salesforce
Apex Trigger in SalesforceCloud Analogy
 
Ivan Gubynskyy Salesforce CRM and Platform Overview
Ivan Gubynskyy Salesforce CRM and Platform OverviewIvan Gubynskyy Salesforce CRM and Platform Overview
Ivan Gubynskyy Salesforce CRM and Platform OverviewLogeekNightUkraine
 
Introducing the Salesforce platform
Introducing the Salesforce platformIntroducing the Salesforce platform
Introducing the Salesforce platformJohn Stevenson
 

Was ist angesagt? (20)

Salesforce Development Best Practices
Salesforce Development Best PracticesSalesforce Development Best Practices
Salesforce Development Best Practices
 
Best Practices with Apex in 2022.pdf
Best Practices with Apex in 2022.pdfBest Practices with Apex in 2022.pdf
Best Practices with Apex in 2022.pdf
 
Salesforce Basic Development
Salesforce Basic DevelopmentSalesforce Basic Development
Salesforce Basic Development
 
Introduction to Apex Triggers
Introduction to Apex TriggersIntroduction to Apex Triggers
Introduction to Apex Triggers
 
Lightning web components episode 2- work with salesforce data
Lightning web components   episode 2- work with salesforce dataLightning web components   episode 2- work with salesforce data
Lightning web components episode 2- work with salesforce data
 
Introduction to the Salesforce Security Model
Introduction to the Salesforce Security ModelIntroduction to the Salesforce Security Model
Introduction to the Salesforce Security Model
 
Maximizing Salesforce Lightning Experience and Lightning Component Performance
Maximizing Salesforce Lightning Experience and Lightning Component PerformanceMaximizing Salesforce Lightning Experience and Lightning Component Performance
Maximizing Salesforce Lightning Experience and Lightning Component Performance
 
Deep Dive into Apex Triggers
Deep Dive into Apex TriggersDeep Dive into Apex Triggers
Deep Dive into Apex Triggers
 
Build Reliable Asynchronous Code with Queueable Apex
Build Reliable Asynchronous Code with Queueable ApexBuild Reliable Asynchronous Code with Queueable Apex
Build Reliable Asynchronous Code with Queueable Apex
 
Salesforce Application Lifecycle Management presented to EA Forum by Sam Garf...
Salesforce Application Lifecycle Management presented to EA Forum by Sam Garf...Salesforce Application Lifecycle Management presented to EA Forum by Sam Garf...
Salesforce Application Lifecycle Management presented to EA Forum by Sam Garf...
 
Real Time Integration with Salesforce Platform Events
Real Time Integration with Salesforce Platform EventsReal Time Integration with Salesforce Platform Events
Real Time Integration with Salesforce Platform Events
 
Salesforce asynchronous apex
Salesforce asynchronous apexSalesforce asynchronous apex
Salesforce asynchronous apex
 
All About Test Class in #Salesforce
All About Test Class in #SalesforceAll About Test Class in #Salesforce
All About Test Class in #Salesforce
 
Lightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An IntroductionLightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An Introduction
 
Salesforce Release Management - Best Practices and Tools for Deployment
Salesforce Release Management - Best Practices and Tools for DeploymentSalesforce Release Management - Best Practices and Tools for Deployment
Salesforce Release Management - Best Practices and Tools for Deployment
 
Batch Apex in Salesforce
Batch Apex in SalesforceBatch Apex in Salesforce
Batch Apex in Salesforce
 
Apex Trigger in Salesforce
Apex Trigger in SalesforceApex Trigger in Salesforce
Apex Trigger in Salesforce
 
Salesforce REST API
Salesforce  REST API Salesforce  REST API
Salesforce REST API
 
Ivan Gubynskyy Salesforce CRM and Platform Overview
Ivan Gubynskyy Salesforce CRM and Platform OverviewIvan Gubynskyy Salesforce CRM and Platform Overview
Ivan Gubynskyy Salesforce CRM and Platform Overview
 
Introducing the Salesforce platform
Introducing the Salesforce platformIntroducing the Salesforce platform
Introducing the Salesforce platform
 

Andere mochten auch

Apex basics-for Beginners
Apex basics-for BeginnersApex basics-for Beginners
Apex basics-for Beginnershrakhra
 
Apex code-fundamentals
Apex code-fundamentalsApex code-fundamentals
Apex code-fundamentalsAmit Sharma
 
Salesforce Presentation
Salesforce PresentationSalesforce Presentation
Salesforce PresentationChetna Purohit
 
APEX navigation concepts
APEX navigation conceptsAPEX navigation concepts
APEX navigation conceptsTobias Arnhold
 
Apex - How to create a master detail form
Apex - How to create a master detail formApex - How to create a master detail form
Apex - How to create a master detail formViveka Solutions
 
Introduction to Apache Apex
Introduction to Apache ApexIntroduction to Apache Apex
Introduction to Apache ApexApache Apex
 
Alt tab - better apex tabs
Alt tab - better apex tabsAlt tab - better apex tabs
Alt tab - better apex tabsEnkitec
 
Salesforce Intro
Salesforce IntroSalesforce Intro
Salesforce IntroRich Helton
 
Salesforce DUG - Queueable Apex
Salesforce DUG - Queueable ApexSalesforce DUG - Queueable Apex
Salesforce DUG - Queueable ApexAkshay Varu
 
High Reliability DML and Concurrency Design Patterns for Apex
High Reliability DML and Concurrency Design Patterns for ApexHigh Reliability DML and Concurrency Design Patterns for Apex
High Reliability DML and Concurrency Design Patterns for ApexSalesforce Developers
 
APEX & MTdoxx
APEX & MTdoxxAPEX & MTdoxx
APEX & MTdoxxMT AG
 
Using Node.js for Mocking Apex Web Services
Using Node.js for Mocking Apex Web ServicesUsing Node.js for Mocking Apex Web Services
Using Node.js for Mocking Apex Web ServicesJeff Douglas
 
How to Get Started with Salesforce Lightning
How to Get Started with Salesforce LightningHow to Get Started with Salesforce Lightning
How to Get Started with Salesforce LightningSalesforce Admins
 
What you need to know on Force.com in 10 slides
What you need to know on Force.com in 10 slidesWhat you need to know on Force.com in 10 slides
What you need to know on Force.com in 10 slidesGuillaume Windels
 
Salesforce Lightning Components Workshop
Salesforce Lightning Components WorkshopSalesforce Lightning Components Workshop
Salesforce Lightning Components WorkshopChristophe Coenraets
 
What is force.com?
What is force.com?What is force.com?
What is force.com?Roy Gilad
 

Andere mochten auch (20)

Apex basics-for Beginners
Apex basics-for BeginnersApex basics-for Beginners
Apex basics-for Beginners
 
Intro to Apex Programmers
Intro to Apex ProgrammersIntro to Apex Programmers
Intro to Apex Programmers
 
Apex code-fundamentals
Apex code-fundamentalsApex code-fundamentals
Apex code-fundamentals
 
Salesforce Presentation
Salesforce PresentationSalesforce Presentation
Salesforce Presentation
 
APEX navigation concepts
APEX navigation conceptsAPEX navigation concepts
APEX navigation concepts
 
Apex - How to create a master detail form
Apex - How to create a master detail formApex - How to create a master detail form
Apex - How to create a master detail form
 
Introduction to Apache Apex
Introduction to Apache ApexIntroduction to Apache Apex
Introduction to Apache Apex
 
Alt tab - better apex tabs
Alt tab - better apex tabsAlt tab - better apex tabs
Alt tab - better apex tabs
 
Salesforce Intro
Salesforce IntroSalesforce Intro
Salesforce Intro
 
Salesforce DUG - Queueable Apex
Salesforce DUG - Queueable ApexSalesforce DUG - Queueable Apex
Salesforce DUG - Queueable Apex
 
High Reliability DML and Concurrency Design Patterns for Apex
High Reliability DML and Concurrency Design Patterns for ApexHigh Reliability DML and Concurrency Design Patterns for Apex
High Reliability DML and Concurrency Design Patterns for Apex
 
APEX & MTdoxx
APEX & MTdoxxAPEX & MTdoxx
APEX & MTdoxx
 
Using Node.js for Mocking Apex Web Services
Using Node.js for Mocking Apex Web ServicesUsing Node.js for Mocking Apex Web Services
Using Node.js for Mocking Apex Web Services
 
Indian it industry
Indian it industryIndian it industry
Indian it industry
 
Visualforce
VisualforceVisualforce
Visualforce
 
How to Get Started with Salesforce Lightning
How to Get Started with Salesforce LightningHow to Get Started with Salesforce Lightning
How to Get Started with Salesforce Lightning
 
What you need to know on Force.com in 10 slides
What you need to know on Force.com in 10 slidesWhat you need to know on Force.com in 10 slides
What you need to know on Force.com in 10 slides
 
Intro to Force.com Webinar presentation
Intro to Force.com Webinar presentationIntro to Force.com Webinar presentation
Intro to Force.com Webinar presentation
 
Salesforce Lightning Components Workshop
Salesforce Lightning Components WorkshopSalesforce Lightning Components Workshop
Salesforce Lightning Components Workshop
 
What is force.com?
What is force.com?What is force.com?
What is force.com?
 

Ähnlich wie Introduction to apex code

Introduction to apex
Introduction to apexIntroduction to apex
Introduction to apexRinku Saini
 
Powershell Tech Ed2009
Powershell Tech Ed2009Powershell Tech Ed2009
Powershell Tech Ed2009rsnarayanan
 
SQL Server 2000 Research Series - Transact SQL
SQL Server 2000 Research Series - Transact SQLSQL Server 2000 Research Series - Transact SQL
SQL Server 2000 Research Series - Transact SQLJerry Yang
 
Salesforce1 Platform for programmers
Salesforce1 Platform for programmersSalesforce1 Platform for programmers
Salesforce1 Platform for programmersSalesforce Developers
 
ADO.NET Data Services
ADO.NET Data ServicesADO.NET Data Services
ADO.NET Data Servicesukdpe
 
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...Knoldus Inc.
 
Play framework training by Neelkanth Sachdeva @ Scala Traits Event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala Traits Event , New Delh...Play framework training by Neelkanth Sachdeva @ Scala Traits Event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala Traits Event , New Delh...Neelkanth Sachdeva
 
Automating Performance Monitoring at Microsoft
Automating Performance Monitoring at MicrosoftAutomating Performance Monitoring at Microsoft
Automating Performance Monitoring at MicrosoftThousandEyes
 
Accelerated data access
Accelerated data accessAccelerated data access
Accelerated data accessgordonyorke
 
Chapter 14 sql injection
Chapter 14 sql injectionChapter 14 sql injection
Chapter 14 sql injectionnewbie2019
 
Preethi apex-basics-jan19
Preethi apex-basics-jan19Preethi apex-basics-jan19
Preethi apex-basics-jan19Preethi Harris
 
PowerShell Technical Overview
PowerShell Technical OverviewPowerShell Technical Overview
PowerShell Technical Overviewallandcp
 
Intro to the Salesforce Command Line Interface for Admins
Intro to the Salesforce Command Line Interface for AdminsIntro to the Salesforce Command Line Interface for Admins
Intro to the Salesforce Command Line Interface for AdminsSalesforce Admins
 
Visual Studio.NET
Visual Studio.NETVisual Studio.NET
Visual Studio.NETsalonityagi
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfoliomwillmer
 

Ähnlich wie Introduction to apex code (20)

My cool new Slideshow!
My cool new Slideshow!My cool new Slideshow!
My cool new Slideshow!
 
Introduction to apex
Introduction to apexIntroduction to apex
Introduction to apex
 
Development withforce
Development withforceDevelopment withforce
Development withforce
 
Powershell Tech Ed2009
Powershell Tech Ed2009Powershell Tech Ed2009
Powershell Tech Ed2009
 
Sql injection
Sql injectionSql injection
Sql injection
 
SQL Server 2000 Research Series - Transact SQL
SQL Server 2000 Research Series - Transact SQLSQL Server 2000 Research Series - Transact SQL
SQL Server 2000 Research Series - Transact SQL
 
Salesforce1 Platform for programmers
Salesforce1 Platform for programmersSalesforce1 Platform for programmers
Salesforce1 Platform for programmers
 
ADO.NET Data Services
ADO.NET Data ServicesADO.NET Data Services
ADO.NET Data Services
 
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
 
Play framework training by Neelkanth Sachdeva @ Scala Traits Event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala Traits Event , New Delh...Play framework training by Neelkanth Sachdeva @ Scala Traits Event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala Traits Event , New Delh...
 
Automating Performance Monitoring at Microsoft
Automating Performance Monitoring at MicrosoftAutomating Performance Monitoring at Microsoft
Automating Performance Monitoring at Microsoft
 
Asp.net tips
Asp.net tipsAsp.net tips
Asp.net tips
 
ELEVATE Paris
ELEVATE ParisELEVATE Paris
ELEVATE Paris
 
Accelerated data access
Accelerated data accessAccelerated data access
Accelerated data access
 
Chapter 14 sql injection
Chapter 14 sql injectionChapter 14 sql injection
Chapter 14 sql injection
 
Preethi apex-basics-jan19
Preethi apex-basics-jan19Preethi apex-basics-jan19
Preethi apex-basics-jan19
 
PowerShell Technical Overview
PowerShell Technical OverviewPowerShell Technical Overview
PowerShell Technical Overview
 
Intro to the Salesforce Command Line Interface for Admins
Intro to the Salesforce Command Line Interface for AdminsIntro to the Salesforce Command Line Interface for Admins
Intro to the Salesforce Command Line Interface for Admins
 
Visual Studio.NET
Visual Studio.NETVisual Studio.NET
Visual Studio.NET
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfolio
 

Kürzlich hochgeladen

Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 

Kürzlich hochgeladen (20)

Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 

Introduction to apex code

  • 1. Coding the Cloud: An Introduction to Apex Code Force.com Platform Fundamentals Andrew Albert, salesforce.com
  • 2. Safe Harbor Statement “Safe harbor” statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward- looking statements including but not limited to statements concerning the potential market for our existing service offerings and future offerings. All of our forward looking statements involve risks, uncertainties and assumptions. If any such risks or uncertainties materialize or if any of the assumptions proves incorrect, our results could differ materially from the results expressed or implied by the forward-looking statements we make. The risks and uncertainties referred to above include - but are not limited to - risks associated with possible fluctuations in our operating results and cash flows, rate of growth and anticipated revenue run rate, errors, interruptions or delays in our service or our Web hosting, our new business model, our history of operating losses, the possibility that we will not remain profitable, breach of our security measures, the emerging market in which we operate, our relatively limited operating history, our ability to hire, retain and motivate our employees and manage our growth, competition, our ability to continue to release and gain customer acceptance of new and improved versions of our service, customer and partner acceptance of the AppExchange, successful customer deployment and utilization of our services, unanticipated changes in our effective tax rate, fluctuations in the number of shares outstanding, the price of such shares, foreign currency exchange rates and interest rates. Further information on these and other factors that could affect our financial results is included in the reports on Forms 10- K, 10-Q and 8-K and in other filings we make with the Securities and Exchange Commission from time to time. These documents are available on the SEC Filings section of the Investor Information section of our website at www.salesforce.com/investor. Salesforce.com, inc. assumes no obligation and does not intend to update these forward- looking statements, except as required by law.
  • 4. Apex Code: Logic-as-a-Service  What is it?  What can it do?  How do I use it?  Well, let‟s see it!
  • 5. Introducing Apex  Force.com allows many customizations through User Interface  Force.com API allows developers to write client-side programs or integrations for more flexibility in their applications – Client side programs have performance costs – Lack transactional control across API requests – Cost and complexity of client hosting server code  APEX was introduced to address those issues and to revolutionize the way developers create on-demand applications.
  • 6. Apex Code Is  Strongly-typed, object-based programming language  Enables developers to execute logic and transaction control statements on Force.com  Runs natively on the server  Code executes on the server when initiated by User Interface via Buttons & Events, and data through the API  Java or C#-like syntax  Transactional
  • 7. How can you use Apex Code?  Database Trigger - Apex Code that is executed in response to a database interaction Example: Apex trigger is initiated whenever a new Contact record is inserted.  Class - Similar to a Java or .NET class - A trigger can call an Apex Class
  • 8. Differences between Triggers and Classes  Triggers execute implicitly in response to a database action  Apex class methods can be explicitly called in many areas of the Force.com  For example: (a) Email to Apex Services (b) Apex Web Services (c) Visualforce controllers
  • 9. How is Apex Different?  Executes directly on the Force.com  Eliminates network traffic between client application and Force.com  Apex Code tightly integrated to the rest of the platform functionality  Changes to the metadata referenced in Apex Code will cause an automatic recompilation the next time those components are executed
  • 10. Language Basics Data Types – Primitive - String - Boolean - Date and DateTime - Integer, Long, Double - ID (Force.com database record identifier) - Blob (for storing binary data) - Sobject (object representing a Force.com standard or custom object) Example: DateTime dt = System.now() + 1; Boolean isClosed = true; String sCapsFirstName = „Andrew‟.toUpperCase(); Account acct = new Account(); //Sobject example
  • 11. Language Basics (cont) Data Types – Collections - Lists - Sets - Maps - Arrays Example: List<Integer> myList = new List<Integer>(); myList.add(12); //Add the number 12 to the list myList.get(0); //Access to first integer stored in the List
  • 12. Language Basics (cont) Statements and Expressions - If/Else - For Loops - Do/While Loops - While Loops Example: Integer count = 0; while(count < 11){ System.debug(„Count = „ + count); count++; }
  • 13. Language Basics (cont) Exception Handling - Try/Catch/Finally statements - Ability to create and throw your own Exceptions Example: public class OtherException extends BaseException {} Try{ //Add code here throw new OtherException(„Something went wrong here…‟); } Catch (OtherException oex) { //Caught a custom exception type here } Catch (Exception ex){ //Caught all other exceptions here }
  • 14. Force.com Query Languages  SOQL – Salesforce object Query Language String myName = „Acme‟; Account[] accts = [select ID from Account where name =:myName] //Pass in a variable  SOSL – Salesforce object Search Language List<List<SObject>> searchList = [FIND '415' IN PHONE FIELDS RETURNING Account, Contact ]; Account [] accounts = ((List<Account>)searchList[0]); Contact [] contacts = ((List<Contact>)searchList[1]);
  • 15. Data Manipulation with Apex  DML (Data Manipulation Language) - Insert - Update - Upsert - Operation to create a new or update existing record based on an external id. - Delete - Undelete
  • 16. Here’s what it looks like Interface Implementation Function Declaration 1 1 global class tasks implements Messaging.InboundEmailHandler { 2 2 3 3 global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, 4 4 Messaging.InboundEnvelope env){ 5 5 6 6 // Create inboundEmailResult object for returning the result of the Force.com Email Service 7 7 Messaging.InboundEmailResult result = new Messaging.InboundEmailResult(); 8 8 9 9 String myPlainText = '‟; Object 101 Instantiation Variable Declaration 111 // Add the email plain text into the local variable 121 try { 131 myPlainText = email.plainTextBody.substring(0, email.plainTextBody.indexOf('<stop>')); 141 } catch (System.StringException e) { 151 myPlainText = email.plainTextBody; Exception 161 System.debug('No <stop> in email: ' + e); Handling 171 } 181 191 // new Task object to be created List Creation Comment 202 List<Task> newTask = new List<Task>(); Syntax 212 222 /* Try to lookup any contacts based on the email from address 232 / If there is more than 1 contact with the same email address 24 / an exception will be thrown and the catch statement will be called 25 */ 262 try { 272 Contact vCon = Id, Name, Email From Contact Where Email = :email.fromAddress] [Select 28 29 ... Query Language
  • 17. Bulk data operations with Apex  Commonly, the ordering of process for an apex solution is as follows: 1) Records are retrieved from the Force.com database with a query statement 2) The array of records ismodified in the processing of your Apex Code 3) The array of records is then sent back to the object through a data manipulation statement These actions are performed in bulk on the Force.com
  • 18. Bulk data operations with Apex (cont)  Apex Code must be designed to handle bulk operations  Why is this important? - The Force.com enforces limits to how many records can be processed at a time (governor limits)  Examples:  Limit on the number of records that can be queried.  Limit on the number of records that be modified.  Limits are calculated by the number of records invoking the Apex Code code
  • 20. Testing  Apex Code to test your Apex Code  Code to help developers perform and automate unit testing  Enables the platform to execute these “test methods” during deployment  Force.com requires that at least 75% of your Apex is covered by testing before code can be deployed to a Production environment (100% is ideal!)  Unit test methods are denoted with testMethod keyword.  testMethods do not modify any data in your org
  • 21. What can you do with Apex Code?  Triggers  Apex Web Services  Email Services  SOA (callouts)  Visualforce Controllers
  • 22. What can you do with Apex Code?  Triggers – Code runs when data changes to ensure business logic is applied – Executes on the server when data changes in either the UI or API.  Email Services – Send & Receive emails, including attachments, with custom logic to process contents. – Includes all standard email attributes, use email templates, and supports plain text or HTML. – Force.com generates a unique email address to process the contents.
  • 23. What else can you do with Apex Code?  Apex Web Services – Develop new Force.com Web Services – Define and expose a custom Web Service for an external service to invoke. – As simple as adding the “webService” keyword to a Apex method – WSDL automatically available  Consume other Web Services – Provides integration with external Web Services – Apex provides integration with Web services that utilize SOAP and WSDL, or HTTP services
  • 24. What else can you do with Apex Code?  Visualforce Controllers – Apex logic accessed by Visualforce pages through custom controllers and controller extensions. – Apex Class that drives the logic when a user interacts with the Visualforce pages.
  • 25. Winter ‘09 Apex Feature – Dynamic Apex  Streamline code design public class displayFields{ …… //Retrieves available SObjects with Global Describe eliminate repetitive code by private Map <String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe(); constructing dynamic procedures //Retrieve accessible fields for specified object public List<Field> showFields(String selectedObject) { for query, search, and data fields.clear(); Map <String, Schema.SObjectField> fieldMap = manipulation schemaMap.get(selectedObject).getDescribe().fields.getMap(); //for each field – determine whether the running user has access to the field  Describe methods for(Schema.SObjectField f : fieldMap.Values()){ Schema.DescribeFieldResult df = f.getDescribe(); if(df.isAccessible()){ New Apex methods to describe fields.add(f); } schema including object definition } return fields; and field definitions. }  User permission awareness The power of system level access with the capability to enforce user permissions and constraints
  • 26. Winter ‘09 Apex Feature – Async Apex global class myclass { public class MyException extends Exception{}  Asynchronous execution public static void throwException() { System.debug('calling throw exception');  Supports web service callouts throw new MyException('for bar'); } from triggers @future(callout=true) static void voidvoid() { System.debug('void void');  Monitoring UI provides Http http = new Http(); HttpRequest req = new HttpRequest(); detailed view of status and req.setMethod('GET'); req.setEndpoint('http://www.cheenath.com'); execution time HttpResponse res = http.send(req); System.debug(res.getBody()); //throw new MyException('for bar'); } @future static void createAccount(String n) { Account a = new Account(name=n); insert a; }
  • 27. Additional Dreamforce 2008 Apex Sessions  Apex Test Coverage Best Practices – Tuesday, 2:00-3:00PM, Esplanade 305  Hands-On : Apex Code – Tuesday, 2:00-3:00PM, South 102  Development As A Service – Building and Deploying Apps in the Cloud – Wednesday, 10:15-11:15AM, Esplanade 303
  • 28. Force.com Library  Books – Developer‟s Guide to the Force.com – Force.com Cookbook – Creating On-Demand Apps  Apex Language Reference
  • 29. Additional Resources  Developer.Force.com – Force.com Developer Community – Apex Developer Guide & Language Reference – Recorded technical presentations and whitepapers – Apex Message Boards  Sign up for free Developer Edition  Training Courses & Certification – DEV401: Force.com essentials – DEV501: Visualforce, Apex, DaaS (Development As A Service)
  • 30. Session Feedback Let us know how we’re doing and enter to win an iPod nano! Please score the session from 5 to 1 (5=excellent,1=needs improvement) in the following categories:  Overall rating of the session  Quality of content  Strength of presentation delivery  Relevance of the session to your organization Additionally, please fill in the name of each speaker & score them on overall delivery. We strive to improve, thank you for filling out our survey.
  • 31. QUESTION & ANSWER SESSION