Book Image

Learning Apex Programming

5 (1)
Book Image

Learning Apex Programming

5 (1)

Overview of this book

Table of Contents (17 chapters)
Learning Apex Programming
Credits
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Welcome aboard! We're about to take a flight together into the realm of Salesforce1 development. We hope that our engaging banter will keep you on the edge of your seat through our thrilling hands-on exploration of the platform, its capabilities, as and its limitations. Our hope is that upon completing this book, you will walk away with the necessary knowledge to build the best application on App Exchange to date!

We ask that you please remain seated until the back cover has fully closed, lock your chairs in the upright position, and prepare yourselves to code like never before! The following sections will now provide you with an overview of our course and brief you on the features of this paper-bound vessel.

We know you have many choices when choosing a learning partner, and we thank you for the chance to become yours.

What this book covers

Chapter 1, Apex Assumptions and Comparisons, serves to introduce you to the Salesforce1 Platform. The Apex programming language, its similarity to Java, and other core concepts will be covered, as well as how to set up a development environment, which will be used throughout the book.

Chapter 2, Apex Limits, covers the limitations of the Salesforce1 Platform, specifically runtime limitations due to the shared tenant architecture. It also covers optimization methods to ensure that these limits are avoided.

Chapter 3, More and Later, which is an extension to the previous chapter, reviews how to process data asynchronously in bulk—leveraging the increased limits in asynchronous processing.

Chapter 4, Triggers and Classes, explains how to create Apex triggers and their respective Apex classes for database manipulation logic.

Chapter 5, Visualforce Development with Apex, allows you to explore how the Apex programming language can interact with the Visualforce markup language to create user interfaces on the Salesforce1 Platform. The chapter progresses from simple examples to more complex, dynamic interactions.

Chapter 6, Exposing Force.com to the World, teaches you how to create public-facing web services and expose your data to the whole wide world through Apex web services hosted on the Salesforce1 Platform.

Chapter 7, Use Case – Integration with Google Calendar, expands upon the knowledge gained in the previous chapter to consume the Google Calendar web service through Apex in order to create a synchronization process between the Salesforce and Google calendars.

Chapter 8, Creating a Property Management Application, covers how to create a property management application from start to finish, complete with credit card processing through the Authorize.net payment gateway.

Chapter 9, Test Coverage, completes your introduction to Apex programming with a fundamental understanding of Test Coverage, its requirements and limitations, and how to write proper tests.

What you need for this book

Those interested in partaking in this adventure with us will require a computer capable of running either the Eclipse IDE or a Sublime Text editor, preferably Sublime Text 3. We have chosen to demonstrate our examples based on the Eclipse IDE; however, Sublime Text users can also complete the exercises. Depending on your choice, either the Force.com IDE plugin for Eclipse or its open source counterpart, MavensMate for Sublime Text will need to be installed.

In addition to the aforementioned software, those wishing to write the code and test it out on the platform will also need a free developer account available from Salesforce (covered in Chapter 1, Apex Assumptions and Comparisons) or a paid license with Apex enabled (either a platform license or Sales Cloud Enterprise or higher).

Who this book is for

This book is intended for developers with prior experience in object-oriented programming development wishing to learn how to develop for the Salesforce1 Platform. It is assumed that you are familiar with the basics of development and do not need to review these concepts before engaging in a discussion about the specifics of the Apex programming language.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "This means that it will not be possible to set the AnnualRevenue variable to a string or IsCustomerPortal to a date."

A block of code is set as follows:

trigger accountTrigger on Account (after insert, after update){

  //Use the Boolean attributes to quickly determine where we are in the order of execution and what operation occurred.
  if ( trigger.isAfter && trigger.isInsert ){
    for ( Account a : trigger.new ){
      if ( a.Phone != null ){
        system.debug(a.Phone);
      }
    }
  }
  if ( trigger.isAfter && trigger.isUpdate ){
    for ( Integer i=0;i<trigger.size();i++ ){
      if ( trigger.new[i].phone != trigger.old[i].phone ){
        system.debug(
        trigger.new[i].phone +'!='+ trigger.old[i].phone 
        );
      }
    }
  }
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

public with sharing class googleAuthorization_Controller {
  public string googleEmail {get;set;}
  //to store our code for dynamic rendering
  public string code {get;set;} 
  //to store our user record
  public User u {get;set;}
  public googleAuthorization_Controller() {
    googleEmail = userInfo.getUserEmail();
  }

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Click on the Setup link at the top-right of the Force.com GUI. Under the Customize section, click on Users (these are not in alphabetical order)."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem..