You are on page 1of 3810

Chapter 3:Best Practices for Writing S-Controls.............................

43
Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents
Mass Updating Contacts When an Account
Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents
Chapter 11:Debugging S-Controls and Apex.................................215
Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents
Chapter 3:Best Practices for Writing S-Controls.............................43
Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents
Mass Updating Contacts When an Account
Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents
Chapter 11:Debugging S-Controls and Apex.................................215
Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents
Chapter 3:Best Practices for Writing S-Controls.............................43
Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents
Mass Updating Contacts When an Account
Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents
Chapter 11:Debugging S-Controls and Apex.................................215
Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents
Chapter 3:Best Practices for Writing S-Controls.............................43
Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents
Mass Updating Contacts When an Account
Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents
Chapter 11:Debugging S-Controls and Apex.................................215
Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents
Chapter 3:Best Practices for Writing S-Controls.............................43
Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents
Mass Updating Contacts When an Account
Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents
Chapter 11:Debugging S-Controls and Apex.................................215
Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents
Chapter 3:Best Practices for Writing S-Controls.............................43
Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents
Mass Updating Contacts When an Account
Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents
Chapter 11:Debugging S-Controls and Apex.................................215
Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents
Chapter 3:Best Practices for Writing S-Controls.............................43
Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents
Mass Updating Contacts When an Account
Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents
Chapter 11:Debugging S-Controls and Apex.................................215
Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents
Chapter 3:Best Practices for Writing S-Controls.............................43
Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents
Mass Updating Contacts When an Account
Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents
Chapter 11:Debugging S-Controls and Apex.................................215
Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents
Chapter 3:Best Practices for Writing S-Controls.............................43
Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents
Mass Updating Contacts When an Account
Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents
Chapter 11:Debugging S-Controls and Apex.................................215
Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents
Chapter 3:Best Practices for Writing S-Controls.............................43
Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents
Mass Updating Contacts When an Account
Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents
Chapter 11:Debugging S-Controls and Apex.................................215
Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents
Chapter 3:Best Practices for Writing S-Controls.............................43
Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents
Mass Updating Contacts When an Account
Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents
Chapter 11:Debugging S-Controls and Apex.................................215
Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents
Chapter 3:Best Practices for Writing S-Controls.............................43
Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents
Mass Updating Contacts When an Account
Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents
Chapter 11:Debugging S-Controls and Apex.................................215
Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents
Chapter 3:Best Practices for Writing S-Controls.............................43
Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents
Mass Updating Contacts When an Account
Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents
Chapter 11:Debugging S-Controls and Apex.................................215
Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents
Chapter 3:Best Practices for Writing S-Controls.............................43
Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents
Mass Updating Contacts When an Account
Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents
Chapter 11:Debugging S-Controls and Apex.................................215
Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents
Chapter 3:Best Practices for Writing S-Controls.............................43
Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents
Mass Updating Contacts When an Account
Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents
Chapter 11:Debugging S-Controls and Apex.................................215
Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents
Chapter 3:Best Practices for Writing S-Controls.............................43
Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents
Mass Updating Contacts When an Account
Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents
Chapter 11:Debugging S-Controls and Apex.................................215
Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents
Chapter 3:Best Practices for Writing S-Controls.............................43
Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents
Mass Updating Contacts When an Account
Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents
Chapter 11:Debugging S-Controls and Apex.................................215
Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents
Chapter 3:Best Practices for Writing S-Controls.............................43
Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents
Mass Updating Contacts When an Account
Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents
Chapter 11:Debugging S-Controls and Apex.................................215
Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents
Chapter 3:Best Practices for Writing S-Controls.............................43
Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents
Mass Updating Contacts When an Account
Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents
Chapter 11:Debugging S-Controls and Apex.................................215
Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents
Chapter 3:Best Practices for Writing S-Controls.............................43
Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents
Mass Updating Contacts When an Account
Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents
Chapter 11:Debugging S-Controls and Apex.................................215
Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents
Chapter 3:Best Practices for Writing S-Controls.............................43
Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents
Mass Updating Contacts When an Account
Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents
Chapter 11:Debugging S-Controls and Apex.................................215
Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents
Chapter 3:Best Practices for Writing S-Controls.............................43
Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents
Mass Updating Contacts When an Account
Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents
Chapter 11:Debugging S-Controls and Apex.................................215
Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents
Chapter 3:Best Practices for Writing S-Controls.............................43
Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents
Mass Updating Contacts When an Account
Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents
Chapter 11:Debugging S-Controls and Apex.................................215
Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents
Chapter 3:Best Practices for Writing S-Controls.............................43
Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents
Mass Updating Contacts When an Account
Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents
Chapter 11:Debugging S-Controls and Apex.................................215
Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents
Chapter 3:Best Practices for Writing S-Controls.............................43
Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents
Mass Updating Contacts When an Account
Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents
Chapter 11:Debugging S-Controls and Apex.................................215
Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents
Chapter 3:Best Practices for Writing S-Controls.............................43
Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents
Mass Updating Contacts When an Account
Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents
Chapter 11:Debugging S-Controls and Apex.................................215
Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents
Chapter 3:Best Practices for Writing S-Controls.............................43
Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents
Mass Updating Contacts When an Account
Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents
Chapter 11:Debugging S-Controls and Apex.................................215
Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents
Chapter 3:Best Practices for Writing S-Controls.............................43
Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents
Mass Updating Contacts When an Account
Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualforce
Page..............................................................265Using AJAX in
a Visualforce
Page....................................................................267Creating
a Wizard with Visualforce
Pages........................................................269
Glossary...........................................................................
............279
iv
Table of Contents

Chapter 3:Best Practices for Writing S-Controls.............................43


Writing S-Controls in
Eclipse............................................................................
44 Writing S-Controls in AJAX
Tools....................................................................45Using
the AJAX Toolkit in an S-
Control...........................................................46Adding a Flex
Application to an S-
Control.......................................................49Using S-Control
Snippets in Other S-
Controls.................................................51Using Special Characters
in URLs and Custom Links.......................................52
Chapter 4: Best Practices for Writing Apex......................................55
Getting Started with
Apex...............................................................................
...56Choosing Between Classes or
Triggers...............................................................59 Writing
Apex in
Eclipse............................................................................
.........60Bulk Processing Records in a
Trigger..................................................................61Controll
ing Recursive
Triggers...........................................................................
62Comparing Queries Against Trigger.old and
Trigger.new..................................66De
f
ning an Apex Web Service and Calling It from an S-
Control.....................67Avoiding Apex Governor
Limits........................................................................70
Writing Unit Tests for
Apex...............................................................................
80Determining Apex Test
Coverage.......................................................................85
Writing Object-Oriented
Apex..........................................................................87
Chapter 5:Searching and Querying Data.........................................93
Using the Force.com Explorer to Examine Your Data
Model............................94Using SoqlXplorer to Examine Your Data
Model..............................................96Choosing Between SOQL and
SOSL................................................................99Constructing
SOQL and SOSL Queries in the Force.com Explorer...............100 Traversing Object
Relationships through the API............................................103Finding
a Contact, Lead, or Person
Account....................................................104Filtering Data Based
on a Relative
Date...........................................................106Finding Data
Based on
Division.......................................................................111P
reviewing Query
Results............................................................................
.....112Sorting Query
Results............................................................................
...........113
Chapter 6: Improving Data Quality...............................................117
Preventing Duplicate Records from
Saving......................................................118Populating a Contact
Edit Page with Default Values from an Account............124Creating a Default
Interviewer Record When a Position is Created................125
ii
Table of Contents

Mass Updating Contacts When an Account


Changes.....................................126
Chapter 7:Customizing Buttons and Links....................................129
Creating a Custom Detail Page
Button............................................................130Creating a
Mass Delete
Button.........................................................................132C
reating a Mass Update
Button.......................................................................135Pas
sing Parameters into a Custom Button or
Link...........................................137Redirecting a User to an Edit,
Detail, or List Page...........................................139Overriding a
Standard Button with an S-
Control............................................139Creating a Button with
Apex............................................................................141
Creating Custom Help for a Custom
Object....................................................143
Chapter 8: Customizing Salesforce Pages and Fields......................145
Mimicking the Salesforce Look-and-Feel in an S-
Control..............................146Displaying Fields from a Related Record on
a Detail Page..............................150Formatting a Currency in an S-
Control............................................................154Creating a
Roll-Up Summary Field with an S-
Control...................................157Allowing Users to Subscribe to Record
Update Noti
f
cations..........................160
Chapter 9:Integrating with Other Services....................................165
Sending Outbound Messages with Work
?
ow..................................................166 Tracking Outbound Messages
from Work
?
ow.................................................168Sending Messages from
Apex...........................................................................169S
ending Data to a Mobile Phone from an S-
Control.......................................173
Chapter 10: Writing Web Controls and Client Applications...........179
Selecting a Development
Language..................................................................180Creati
ng an Integration
User............................................................................180
Selecting a
WSDL...............................................................................
.............181Generating a WSDL
Document......................................................................182Us
ing the Partner
WSDL...............................................................................
..183Logging In to the
API................................................................................
......186Managing
Sessions...........................................................................
.................188Changing the Session Timeout
Value...............................................................190Implementing
the Query/Query More
Pattern................................................191Batching Records for API
Calls........................................................................192Usi
ng a Wrapper Class for Common API
Functions.......................................195Building a Web Portal with
Salesforce Data.....................................................208
iii
Table of Contents

Chapter 11:Debugging S-Controls and Apex.................................215


Best Practices for Debugging S-
Controls.........................................................216Debugging HTTP
Requests with
Fiddler........................................................217Debugging S-
Controls with
Firebug................................................................219Debugging
S-Controls with IE DOM
Explorer..............................................224Understanding Browser
Differences.................................................................226Best
Practices for Debugging
Apex...................................................................228Debugging
Apex in
Salesforce.........................................................................
.229Debugging Apex in
Eclipse............................................................................
..229
Chapter 12: Packaging an App for the AppExchange......................233
Deciding Whether to Make a Package Managed or
Unmanaged.....................234Registering a Namespace Pre
f
x........................................................................235Using
Namespaces in S-Controls and
Apex.....................................................237Using Namespaces in a
Client
Application.......................................................238Creating an
Unmanaged Package from a Namespaced Organization...............239 Tracking Package
Users..............................................................................
......240Posting a Package on the
AppExchange...........................................................242Upgrading
a Released
Package..........................................................................24
5Converting an Unmanaged Package into a Managed Package.........................246
Chapter 13:Getting Started with Visualforce.................................249
Enabling Visualforce in your
Organization.......................................................250Enabling
Visualforce Developer
Mode.............................................................250Creating Your
First Visualforce
Page................................................................251Using the
Visualforce Component
Library.......................................................255Creating Your
First Visualforce
Controller.......................................................258Using Query
String Parameters in a Visualforce
Page......................................261Building a Table of Data in a
Visualforce Page.................................................263Building a Form
in a Visualfor

You might also like