Force Platform Fundamentals Final
Force Platform Fundamentals Final
Force Platform Fundamentals Final
By Chris McGuire
Caroline Roth
With contributions by
Dave Carroll
Nick Tran
Andrea Leszek
Force.com Platform Fundamentals
© Copyright 2000-2010 salesforce.com, inc. All rights reserved. Salesforce.com is a registered trademark
of salesforce.com, inc., as are other names and marks. Other marks appearing herein may be
trademarks of their respective owners.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any
form, or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the
prior consent of the publisher.
ISBN: 978-0-9789639-2-7
With special thanks to Grant Anderson, Steve Anderson, Mysti Berry, Eric Bezar, Phil Choi, Steve
Fisher, Ron Hess, Paul Kopacki, Vahn Phan, Mary Scotton, Andrew Smith, Tom Tobin, Adam Torman,
Andrew Waite, Sarah Whitlock, and the salesforce.com Training & Certification team.
Table of Contents
Table of Contents
Preface......................................................................................................1
Welcome to the Cloud!.....................................................................................................1
Platforms for Cloud Computing...........................................................................2
About This Book..............................................................................................................2
Intended Audience................................................................................................3
Chapter Contents.................................................................................................3
Choosing Your Development Environment..........................................................5
Sending Feedback.................................................................................................5
About Developer Force.....................................................................................................5
i
Table of Contents
ii
Table of Contents
iii
Table of Contents
iv
Table of Contents
v
Table of Contents
vi
Table of Contents
vii
Table of Contents
Glossary................................................................................................315
Index.....................................................................................................339
viii
Preface
As users of the Internet, we're all familiar with the fascinating, innovative, creative, and sometimes
silly ways in which it has changed how we work and play. From social networking sites to wikis
to blogs, and more, it’s exciting to watch the innovations taking place that are changing the ways
we communicate and collaborate.
While these changes have certainly impacted how we work with content, a similar set of
Internet-driven ideas and technologies is changing how we build and work with business
applications. While yesterday's business applications required thousands, if not millions, of
dollars and sometimes years of professional services help to set up and customize, the technologies
offered by the Internet today make it much easier to create, configure, and use business
applications of all kinds. Indeed, the power of the Internet has given us the ability to solve new
kinds of business problems that, because of complexity or cost, had previously remained out of
reach.
Just as the changes that moved publishing technology from paper to bits made it possible for us
to have information about anything in the whole world right at our fingertips, the changes in
application technology make it similarly possible to imagine a robust, enterprise-class application
for almost any business need. Sound pretty good? Then you're probably wondering: “What's
the magic that makes this possible?”
1
Preface
Because almost all apps these days are delivered via a Web browser, it's increasingly hard to
tell which applications are “traditional software,” and which are run in the cloud. As with the
Internet, applications that run in the cloud have grown so ubiquitous that almost every business
user interacts with at least one, whether it's an email service, a Web conferencing application,
or a sales system.
Similar to traditional platforms, cloud computing platforms provide tools that allow developers
to leverage existing functionality to create something new; however, because these platform
tools are accessed freely over the Internet rather than through an operating system or package
that was installed on a local machine, developers don't need to worry about the logistics of
putting together an executable that will be installed on a user's machine. Anyone with a Web
browser can access it!
The possibilities presented by this new type of platform have emerged quickly, spurred on by
the popularity of mash-ups—a website or application that combines tools from multiple cloud
computing platforms to create new functionality. Some of the cloud computing platform tools
used in today's mash-ups include innovations like Google's search API, which allows developers
to use the power of that search engine in their applications, eBay's APIs for auctions and
listings, or Amazon.com's system for creating entirely new storefronts. For example, almost
any real estate website or application these days uses Google or Yahoo! maps under the hood,
illustrating how these new APIs are now commonly running alongside the more traditional
database, app server, or operating system platforms.
To illustrate the technologies available on the Force.com platform, and to show you just how
easy it is to create your own business application with the platform, this book walks you through
the process of creating a new recruiting application that runs in the cloud. To follow along you
won't need to learn any programming languages or hack your way through cryptic configuration
2
Preface
documents—instead, you'll just need to point-and-click your way through a Web interface,
following the easy step-by-step instructions in the book.
Intended Audience
This book can be easily understood by anyone from a business user to a professional developer.
However, to get the most out of the book, it helps to be familiar with basic Internet and
database concepts, such as tables and fields.
While the book focuses primarily on using the point-and-click functionality of the Force.com
platform, Chapter 10 introduces you to the platform's user interface programming tools and
how you can use them to build customer-facing websites. To fully understand that chapter,
you should be familiar with HTML and JavaScript. However, all the code you need is provided,
so even if you're not an experienced developer, you can still follow along to gain a deeper
understanding of what can be done with the Force.com platform.
Chapter Contents
If you're already familiar with the Force.com platform, you can skip around to the chapters in
which you're most interested:
3
Preface
• Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts on
page 52
Add picklists, dependent picklists, validation rules, and formula fields to the custom object,
and then edit the layout of the object's detail page.
Note: This book contains lots of screenshots. Because the Force.com platform is a
rapidly developing platform, the screenshots might vary slightly from what you see on
the screen, but don't worry! These differences should be minor and won't affect your
understanding of the system.
4
Preface
Sending Feedback
Questions or comments about anything you see in this book? Suggestions for topics that you'd
like to see covered in future versions? Go to the Developer Force discussion boards at
community.salesforce.com/sforce?category.id=developers and let us know
what you think! Or email us directly at developerforce@salesforce.com.
5
Preface
To find out more about the resources available on the Developer Force website, see
developer.force.com.
6
Chapter 1
Introducing the Force.com Platform
In this chapter ... The Force.com platform is the world's first Platform as a
Service (PaaS), enabling developers to create and deliver any
• The Basics of an App kind of business application in the cloud, entirely on-demand
• The Benefits of a and without software. It's a breakthrough new concept that
Force.com Platform App is making companies radically more successful by letting
• The Technologies Behind them translate their ideas into applications in record time.
a Force.com Platform App Building, sharing, and running business applications has
never been so easy.
7
Chapter 1: Introducing the Force.com Platform
Tabs
As you can see when you start clicking around, there are a few key elements that form the
foundation of the Sales Automation app and of most applications created with the platform.
First, across the top of the app is a set of tabs that segment the app into different parts. Each
tab corresponds to a type of object, such as an account or contact, and within a tab you can
perform actions on particular records of that tab's type. For example, when you click on the
Accounts tab, you can create a new record for the “Acme” account. You can also edit existing
accounts, or use a list view to filter lists of accounts by certain criteria. Most app development
work revolves around creating tabs and defining the data and behaviors that support them.
Forms
A second key element is the form that is displayed as part of a tab. As in any business app,
forms are the primary means of entering and viewing information in the system. Forms allow
you to view and edit the data associated with a particular record on a tab, like the contact
“Jerome Garcia” on the Contacts tab. When developing a new app you can define what
information appears in each form, and how it is organized. For example, the form for a contact
record includes fields such as Last Name, Home Phone, Mailing City, Title,
Birthdate, Reports To, and Account. In a Force.com platform app, the form used to
enter information is referred to as an edit page and the read-only view of that information is
referred to as a detail page.
Links
Finally, because Force.com platform apps are delivered via a Web browser, they use links to
provide navigation to related data. For example, on an account detail page, there are links to
8
Introducing the Force.com Platform
related records, such as the contacts who belong to the account and the sales user who manages
the account. Other links take you to recently visited records and to areas of the app where users
can set personal preferences. These links provide navigation both within an app and out into
the Web.
Figure 1: Force.com Platform Apps Include Tabs, Detail Pages, and Links
Data-Centric Apps
Because the platform is centered around a database, it allows you to write apps that are
data-centric. A data-centric app is an application that is based on structured, consistent
information such as you might find in a database or an XML file. We can find these data-centric
apps everywhere, in small desktop databases like Microsoft Access or FileMaker, all the way
to the huge systems running on database management systems like Oracle or MySQL. Unlike
applications that are built around unstructured data, like plain text documents or HTML files,
data-centric apps make it easy to control, access, and manage data.
9
Chapter 1: Introducing the Force.com Platform
For example, consider an exercise such as trying to determine the total sales for a month from
a set of Microsoft Word-based contracts versus a set of contracts in a simple database. Whereas
it takes a lot of effort to open each Word document, find the contract total, and then add them
all together, if this data is stored in the database of a data-centric app, we can more efficiently
get the same result by issuing a single query.
While most people don't need a data-centric application to keep track of anything other than
contacts, photos, or possibly music, companies of all sizes constantly need to query and aggregate
their large amounts of data to make fast business decisions. As a result, the data-centric nature
of the Force.com platform makes it the perfect platform to build and host business applications.
Collaborative Apps
Because the platform can be accessed by multiple users at the same time, it also allows you to
write apps that are collaborative. A collaborative app is an application with data and services
that are shared by multiple users in different locations. Unlike more traditional forms of software
that are installed on a single machine and are hard to access from a distance, collaborative apps
on the platform can be accessed from anywhere in the world with only a Web browser. This
makes it easy for teams to work together on activities like selling a product, managing a project,
or hiring an employee.
In addition to easy access over a Web browser, a number of built-in platform features also
facilitate productive group collaboration:
• The platform's security and sharing model allows you to finely control a user's access to
different data
• Workflow rules allow you to automatically assign tasks, update data, or send email alerts
when certain business events occur, such as the creation of a new record or a change in the
value of a record field
• Approval processes allow you to set up a sequence of steps necessary for a record to be
approved, including who must approve it at each step
Collectively, these features provide a framework for sharing apps across groups, divisions, and
entire corporations without relinquishing administrative control over sensitive data.
10
Introducing the Force.com Platform
Technology Description
Multitenant An application model in which all users and apps share a single,
architecture common infrastructure and code base
Metadata-driven An app development model that allows apps to be defined as
development model declarative “blueprints,” with no code required. Data models, objects,
forms, workflows, and more are defined by metadata.
Web services API An application programming interface that defines a Web service that
provides direct access to all data stored in the Force.com platform
from virtually any programming language and platform
Apex The world’s first on-demand programming language, which runs in
the cloud on the Force.com platform servers
Visualforce A framework for creating feature-rich user interfaces for apps in the
cloud
Sites Public websites and applications that are directly integrated with your
Salesforce.com organization—without requiring users to log in with
a username and password
AppExchange A Web directory where hundreds of Force.com apps are available to
directory Salesforce.com customers to review, demo, comment upon, and/or
install. Developers can submit their apps for listing on the
AppExchange directory if they want to share them with the
community.
A Multitenant Architecture
The platform's multitenant architecture means that all users share the same physical instance
and version of any application that runs on it. In contrast to their single-tenant counterparts,
such as client-server enterprise applications or email servers, multitenant applications are
designed so that any upgrades to the platform or the apps it supports happen automatically for
all users at once. Consequently, no one has to worry about buying and maintaining their own
physical stack of hardware and software, or making sure that their applications always have
the latest patch installed.
Besides the Force.com platform, several popular, consumer-based applications also use a
multitenant architecture, including eBay, My Yahoo!, and Google Mail. Multitenant architecture
11
Chapter 1: Introducing the Force.com Platform
allows these applications to be low cost, quick to deploy, and open to rapid innovation—exactly
the qualities for which salesforce.com has also become known.
The platform's multitenant architecture also impacts how developers use the platform to create
new applications. Specifically, it defines a clear boundary between the platform and the
applications that run on it. A boundary is important because it allows applications to define
their own components without jeopardizing the functionality of the core platform or the data
stored by other users.
12
Introducing the Force.com Platform
Customizing your app's metadata might sound intimidating, but as you'll see in this book, the
platform's user interface makes it easy. Anyone who is familiar with using a Web browser can
quickly get up to speed, even if he or she doesn't know any programming languages.
Tip: Developers can use the Force.com Metadata API to programmatically manage their
app's setup. The Force.com Metadata API provides an alternative to the platform's user
interface by allowing developers to directly modify the XML files that control their
organization's metadata. Developers can also use the Metadata API to migrate
configuration changes between organizations, and create their own tools for managing
organization and application metadata. For information on the Metadata API, see
http://www.salesforce.com/us/developer/docs/api_meta/index.htm.
Although at first glance metadata-driven development may seem somewhat esoteric, it's exactly
the same model for how Web browsers work. Instead of hard coding the definition of a Web
page in a free-form programming language, a Web page author first defines the page as HTML,
which is itself a kind of metadata. When a user requests a page, the Web browser renders the
page using the metadata provided in the HTML tags. Even though the HTML/browser
combination does not allow authors as much formatting power as they might get in a regular
publishing tool, it simplifies the work of publishing content to a wide audience and increases
the Web page author's overall productivity.
Likewise, the Force.com platform vastly simplifies the work of building an app and increases
a developer's overall productivity. And, like Web pages that use JavaScript or Flash to add
functionality to HTML pages, the Force.com platform also provides ways for more advanced
developers to add custom functionality to the apps you build.
The API provides a straightforward, powerful, and open way to programmatically access the
data and capabilities of any app running on the platform. It allows programmers to access and
manipulate apps from any server location, using any programming language that supports Web
services, like Java, PHP, C#, or .NET. Because Web services are, not surprisingly, based on
Web standards, they're well suited to traverse firewalls and leverage the rest of the Internet
infrastructure already in place.
13
Chapter 1: Introducing the Force.com Platform
Apex
As you might expect from the company that delivered the world's first cloud computing
platform, salesforce.com also introduced the world’s first cloud computing programming
language, Apex. Apex is based on Java, the most popular programming language for Web apps,
and runs on the Force.com platform servers. Apex is specifically designed for building business
applications to manage data and processes within the larger context of the Force.com platform.
The language provides a uniquely powerful and productive approach to creating functionality
and logic, allowing developers to focus just on the elements specific to their application, while
leaving the rest of the “plumbing” to the Force.com platform.
The majority of this book is intended for readers who don't necessarily code, so Apex is beyond
the scope of what we'll discuss here; however, you can learn everything there is to know about
Apex at
http://wiki.developerforce.com/index.php/Apex_Code:_The_World's_First_On-Demand_Programming_Language.
Visualforce
At the front of any great business application is a great user interface that's easy to use, powerful,
and suited exactly for the tasks, users, and devices the application serves. Visualforce is a
complete framework for creating such user interfaces, enabling any kind of interface design
and interaction to be built and delivered entirely in the cloud. The user interfaces you build
with Visualforce can extend the standard Force.com platform look and feel, or replace it with
a completely unique style and set of sophisticated interactions. Because Visualforce markup is
ultimately rendered into HTML, designers can use Visualforce tags alongside standard HTML,
JavaScript, Flash, or any other code that can execute within an HTML page on the platform.
And that's only the beginning: you can also use Visualforce pages to combine data from multiple
Force.com platform objects, or blend data from Web services into your applications, as we
discuss in Moving Beyond Point-and-Click App Development on page 273.
Sites
The apps you build on the Force.com platform might contain data and functionality that you
want to make accessible to people who are not Salesforce.com users. While it is possible to use
the Web services API to integrate an external Web page or application with Salesforce.com,
the Force.com platform provides an easier, more efficient way of sharing data and functionality
with people outside of your organization: Sites.
Sites enables you to create public websites and applications that are directly integrated with
your Salesforce.com organization—without requiring users to log in with a username and
14
Introducing the Force.com Platform
password. You can publicly expose any information stored in your organization through pages
that match the look and feel of your company's brand. Because these sites are built and hosted
on the Force.com platform servers, there are no data integration issues. And because sites are
built with Visualforce pages on the platform, data validation on collected information is
performed automatically.
15
Chapter 2: About the Sample Recruiting App
Chapter 2
About the Sample Recruiting App
In this chapter ... The goal of this book is to show you how easy it is to create
powerful, multifaceted applications that solve common
• About Universal business problems. To do so, let's walk through the steps of
Containers creating a simple application for a make-believe company
• Considerations for the called Universal Containers.
Recruiting App
Like many companies that have grown rapidly, Universal
• Building the App: Our
Containers has been experiencing a few growing pains,
Design
especially in its Human Resources department. In this book,
we're going to build a Recruiting app for the company that
allows it to move away from the Microsoft Word documents
and Microsoft Excel spreadsheets that it has traditionally
used to an application that's available on demand.
16
About the Sample Recruiting App
Historically, the Human Resources department has used Microsoft Word documents and
Microsoft Excel spreadsheets to manage the recruiting and hiring process for new employees.
However, over the last two quarters it's become evident that unless this process is replaced by
one that is more collaborative, reliable, and scalable, the department won't be able to meet its
hiring goals for this fiscal year. Universal Containers needs a centralized application that can
bring all of its recruiting and hiring processes together, and the company has hired us to solve
this problem. Our approach will be to leverage their Salesforce.com account and build a
recruiting application on the Force.com platform. We're going to introduce Universal Containers
to the world of cloud computing!
• Track positions in all stages of the process, from those that are open to those that have
been filled or canceled
• Track all of the candidates who apply for a particular position, including the status of their
application (whether they've had a phone screen, are scheduled for interviews, have been
rejected or hired, or have passed on an offer that was presented)
• Track the posting of jobs on external employment websites, such as Monster.com
• Allow employees to post reviews for candidates whom they've interviewed
• Provide security for the recruiting data so that it's not mistakenly viewed, edited, or deleted
by employees who shouldn't have access
• Automatically inform the relevant recruiter about the next steps that should be taken when
a decision has been made about an applicant
• Automatically inform all employees of new positions that have been posted
17
Chapter 2: About the Sample Recruiting App
• Make sure that a new job opening has executive approval before it becomes active
• Include reports that give users an overview of recruiting status
• Allow recruiters to map the locations of all candidates who are applying for a position, to
better understand relocation expenses
• Make it easy to perform several similar tasks at once, like rejecting multiple job applications
• Automatically post open positions on Universal Containers' public website
An app that meets these requirements is going to greatly increase the efficiency of Universal
Containers' recruiting and hiring processes.
Custom Objects
Custom objects are the native components that model the data we need to store in our
Recruiting app. Similar to a database table, a custom object is composed of several fields that
store information such as a job applicant's name, or the maximum salary for a particular position.
However, unlike traditional database tables, we don't need to write any SQL in order to create
custom objects. We can simply point and click in the platform to create as many objects as we
need.
For our Recruiting app, we'll be creating six custom objects to track recruiting-related data:
• Position
• Candidate
• Job Application
• Review
• Job Posting
• Employment Website
Most of these objects will be displayed as tabs in our application. When a user clicks one of
the tabs, he or she will have access to individual instances of that particular object, as shown
in the following screenshot.
18
About the Sample Recruiting App
One of the powerful features of a custom object is the fact that it can have relationships with
other objects in the system. For example, for every review written by an interviewer and entered
into the system, we'll want to associate it with the job application of the candidate who was
being interviewed. Again, we won't need to write any SQL to make this happen—thanks to
the platform, defining a relationship will be as simple as a few clicks of the mouse.
With security and sharing rules, we'll first specify which custom objects a particular user should
be allowed to create, view, or edit (for example, Candidate and Position), and then which
instances of those objects should be accessible (for example, the records for candidate John
Smith or the Senior Sales Manager position). Controlling our data either with the wide brush
of object-level security or with the more detailed brush of record-level security will give us a
lot of power and flexibility in controlling what users can and can't see.
19
Chapter 2: About the Sample Recruiting App
openings for executive approval. Once again, the Force.com platform makes these requirements
easy for us to implement natively with the built-in workflow and approval process components.
Workflow and approval processes allow us to create business logic based on rules:
• Workflow rules can assign tasks to users, update fields, or send email alerts
• Approval processes allow users to submit sensitive records like new contracts or purchase
orders to other users for approval
For example, in our Recruiting app, we can create a workflow rule that triggers an event
whenever the status of a job application has changed to Reject or Extend an Offer, as illustrated
below.
When a hiring manager makes a decision to either extend an offer to or reject the candidate,
changing the status of the application triggers the appropriate task to be assigned to the recruiter
for that position. Based upon the hiring manager’s decision, the recruiter performs the
appropriate follow-up task.
Similarly, we can define an automatic approval process that sends all new positions to the
appropriate management for approval. If the position is approved, its status automatically
changes to Open - Approved and recruiters can start the hiring process. If the position is
rejected, its status automatically changes to Closed - Not Approved and the position won't be
filled.
20
About the Sample Recruiting App
We can meet these requirements with the custom report wizard and dashboards. The wizard
allows us to create detailed reports with filters, conditional highlighting, custom subtotals, and
charts, while dashboards allow us to display a group of up to 20 different report charts on a
single page.
Visualforce
We'll be able to use point-and-click tools to satisfy nearly all of our Recruiting app use cases;
however, there are a few use cases, such as the mapping of candidate locations and the posting
of positions on Universal Containers' public jobs site, that will require us to use Visualforce,
the Force.com platform's tag-based markup language that allows you to build sophisticated,
custom user interfaces for apps. We won't address these use cases until the very last chapter,
and when we do, this book will provide all the code you need.
Although we haven't yet gone into detail about how any of this stuff is going to work, you can
probably see now just how flexible and powerful the Force.com platform can be when you're
creating a custom app.
In the next chapter, we'll start out by building our first custom object. We'll swiftly get a feel
for how the platform interface works, and it won't be any time at all before you're building app
components easily and quickly. When it's this easy, you can't help but become an expert!
21
Chapter 3: Reviewing Database Concepts
Chapter 3
Reviewing Database Concepts
In this chapter ... Now that we've introduced the power of the Force.com
platform and learned about the requirements of the
• What's a Database? Recruiting app that we're going to be building, let's take a
• What's in a Database? moment to talk about databases and why a simple
• What's a Relational understanding of database concepts can help you realize the
Database? full potential of the platform and make your app
• Summary of Database development a whole lot easier.
Concepts As you know, the underlying architecture of the platform
includes a database where your data is stored. This means
that all of the information you enter is stored in that database
and then retrieved from the database whenever you view it
within your app.
22
Reviewing Database Concepts
What's a Database?
In simple terms, a database is an organized collection of information. Common examples
include a phone book, a library catalog, an employee directory, a catalog of the MP3s you own,
or in the case of our Recruiting app, information about the open positions at a company, the
people who are applying for those positions, and the managers at our company who are in
charge of hiring each position.
Typically, you use a database to collect information about people, things, or concepts that are
important to you and whatever project you're working on. In standard database language, the
category of person, thing, or concept you want to store information about is referred to as an
entity, although in standard Force.com platform terminology, we refer to this as an object.
In our Recruiting app, we'll have one table to store information about open positions, another
table to store information about the candidates applying for the positions, and a table to store
information about hiring managers. (Our Recruiting app will have more than just this, but
we'll get to that later.)
In very simplistic terms, a Force.com platform object is similar to a database table in that you'll
have a separate object for each person, thing, or concept about which you want to collect
information. In reality, a Force.com platform object is much more than this because the full
functionality of the platform is behind each object. Each object automatically has built-in
features like a user interface, a security and sharing model, workflow processes, and much more
that you'll learn about in the rest of this book.
It's important to understand that a single database table, or Force.com platform object, should
contain only one type of information. You don't want to lump all of your information into one
table, so you wouldn't store positions, candidates, and hiring managers all in the same place.
Not only is this not good database design, but it doesn't allow you to relate objects to one
another. For example, if all of our data were in one table, how would we ever know which
23
Chapter 3: Reviewing Database Concepts
candidates were applying for which positions, or which managers were in charge of hiring for
which positions?
As we define our app, it's important for us to keep this in mind and ask ourselves questions
like, “What kind of information do we want to store? Can we separate our information into
distinct categories so that each object holds only one type of person, thing, or concept?” The
answers to these questions will guide us as we design the structure of our application.
What's in a Database?
As we mentioned, a database table presents your information in rows and columns. Let's take
a look at how a table of positions might look:
Each row in the table represents the information about a specific instance of the object, for
example, the Recruiter position or the SW Engineer position. In standard Force.com platform
terminology, we call this a record. For every object you want to track in your app, you'll have
multiple records to represent each individual item about which you're storing information. It's
common for users who are new to the platform to confuse the meanings of object and record.
It'll make your development a lot easier if you remember that an object is a category of
information, such as a position or candidate, and the record is a single instance of an object,
such as a SW Engineer.
Note: As a side note here, we'll mention that the platform includes a set of built-in
objects when you first start using it; we call these standard objects. One example of a
standard object is the User object, which stores information about each person who
is a user of the app, like our hiring managers. You can also build your own objects to
store information that's unique to your app; we call these custom objects. Both standard
24
Reviewing Database Concepts
objects and custom objects are not really all that different—one kind is prebuilt for
you, and the other you build yourself. We'll talk more about these later as you start to
build your app.
Now let's look at the columns in the table. Each column lists a particular piece of information
such as the Position Title or Max Pay. We refer to these as fields. Every object has a set of
fields that you use to enter the information about a particular record. For each field in the
table, a single item of data that you enter, such as Human Resources in the Functional Area,
is referred to as a data value.
Just like objects, fields come in two varieties: standard and custom. The standard fields are the
ones that are built into the platform and automatically added for you. The custom fields are
the ones you define to store specific pieces of information that are unique to your app.
Fundamentally, there is no difference between standard and custom fields. Both are simply
columns in the database table. We'll talk more about standard and custom fields later when
you begin building your app.
But what if a hiring manager is responsible for hiring more than one position? You would need
to have duplicate records for the same hiring manager so you could capture every position for
which that hiring manager is responsible, like this:
25
Chapter 3: Reviewing Database Concepts
This is not a good database design! Using this approach, data is repeated unnecessarily. In
addition, there is really no way to capture additional information about our hiring managers,
like their email addresses or phone numbers. And if we try to add information about which
candidates are applying for each position, you can imagine that our simple table will quickly
become extremely complex and unmanageable.
As we mentioned before, you want to create separate database tables, or objects, for each person,
thing, or concept you want to track. A better way to model our scenario here would be to create
one object for positions, one object for candidates, and one object for hiring managers. (Luckily,
the platform has a standard object that we'll be able to use to represent our hiring managers—the
User object.)
Once we have our data separated into discrete objects, we can easily relate objects to each other.
This is what a relational database is all about! A relationship is an association between two or
more tables. For example, we can relate positions to hiring managers so we know which positions
each hiring manager is responsible for:
From a technical standpoint, each table in a relational database has a field in which the data
value uniquely identifies the record. This field is called the primary key. The primary key is one
part of what defines the relationship; the other part is the foreign key. A foreign key is a field
whose value is the same as the primary key of another table. You can think of a foreign key as
a copy of a primary key from another table. The relationship is made between two tables by
matching the values of the foreign key in one table with the values of the primary key in another.
Primary and foreign keys are fundamental to the concept of relationships because they enable
tables to be related to each other. As you begin building your app, you won't really need to
think too much about primary keys and foreign keys. The important concept to understand
here is that in a relational database, objects are related to each other through the use of common
fields that define those relationships.
Now that we've got that all covered, let's get started building our first object!
27
Chapter 4: Building a Simple App
Chapter 4
Building a Simple App
In this chapter ... Just as traditional programming books first teach you how
to write a simple “Hello World” program before getting into
• Becoming Familiar with more complicated things, in this chapter, we're going to
the Setup Area create a very simple version of the Recruiting app to show
• Introducing Apps you just how easy it is to get started with the Force.com
• Introducing Objects platform. Along the way we'll orient ourselves to the
• Introducing Tabs platform's user interface (where we'll be doing most of our
work), and we'll learn how to create and configure our first
• Becoming Familiar with custom object. Although easy and straightforward, the tasks
Setup Detail Pages and we complete here will be the first step in developing a
Related Lists full-featured Recruiting app. So let's dive right in!
• Introducing Fields
• Look at What We've
Done
28
Building a Simple App
The Setup area is a user preferences area, an application building and customization
environment, and an administration tool, all in one. We perform almost every task we need
to create our app in the Setup area, so most of the “Try It Out” sections of the book are going
to start with an instruction like, “Click Your Name ➤ Setup ➤ Create ➤ Apps.” This is a
short way of saying:
1. Click the Your Name ➤ Setup link in the top-right corner of the page (shown in
the following screenshot).
2. Go to the App Setup area on the left side of the page.
3. Click the + icon to expand the Create menu, or just click the Create link.
4. Click the Apps link.
The final link that you click (in this example, Apps) will change depending on the task you're
trying to perform, but you get the general idea.
Similar to the other parts of the application, the Setup area consists of a tab bar, a navigational
sidebar, and a main window:
29
Chapter 4: Building a Simple App
• The tab bar is made up of the same tabs that appear in the regular application. Just click
on any one of the tabs to exit the Setup area and go to that tab in the main application.
• The navigational sidebar includes expandable lists of all the tools that are available in the
Setup area:
Personal Setup
These tools control individual preferences and are available to all users.
App Setup
These tools configure the standard objects, custom objects, and custom
apps that are deployed and are typically used only by administrators.
Administration Setup
These tools configure the platform as a whole and are typically used
only by administrators.
Force.com Checkout
These tools let you purchase licenses and products from salesforce.com,
change your billing information, and so forth.
• The main window is where the navigational links or a selected setup tool are actually
displayed.
Now that we know what we're looking at, let's start creating our simple app.
Introducing Apps
What should we do first? If we were writing a software application, the first thing we'd need
to do is build a project where we could store all the code that we were going to write. With
the Force.com platform, the first thing we need to do is create a new app.
Like a programming project, an app is little more than a container for all of the objects, tabs,
and other functionality that we're going to build as part of our Recruiting application. It consists
simply of a name, a logo, and an ordered set of tabs. The simplest app contains only one
tab—the Home tab—and a default logo. As we define more tabs in the remainder of this book,
we can add them to the app later.
Let's start clicking through the process of actually creating a simple app now. Log in to your
Salesforce.com account so you can follow along!
Note: Because the platform is continually evolving, you might find that the screenshots
you see in this book vary slightly from what you see on your screen. These changes
should be minor and shouldn't affect your understanding.
30
Building a Simple App
Note: You'll find that many parts of the application have these splash pages
to help you understand what you can do with the platform. If you never
want to see a particular page again, just click Don't show me this page again.
Welcome to the Apps list page! Like many of the setup tools, the starting page for the Apps
tool consists of a list of all the apps that are currently enabled for your organization. Depending
on what edition you're using or what you've already installed from the AppExchange, you'll
probably already have some standard apps listed here.
6. Click New.
The New Custom App wizard appears.
The app label is the name that will represent our new app in the Force.com app menu that
appears at the top right of all pages. Users can use this menu to switch back and forth between
apps.
Notice that a vertical red bar appears just to the left of this Label field. This red bar indicates
that you must provide a value for this field in order to save your work. If you don't enter a value
here and try to proceed, an error message is displayed, as shown in the following screenshot.
31
Chapter 4: Building a Simple App
The app name is what the developers use to identify an app when writing code for the Force.com
platform. We won't be doing anything in this book that uses the app name, but the field is
required, so it needs a value. Fortunately, when you enter a value in the App Label field, the
same value should automatically appear in the App Name field. If it doesn't, enter Recruiting
in the App Name field now.
The next screen in the New Custom App wizard allows you to specify the image file that
should be used for this app's logo. Whenever the app is selected in the Force.com app menu,
this is the logo that appears in the upper-left corner of all pages. Since we're just creating a
simple app, let's accept the default logo that's already provided. We can always change it later.
As we said before, an app is a container for an ordered collection of tabs, and this step of the
New Custom App wizard allows us to specify which tabs we want to include in our new app.
The Available Tabs list shows us the standard and custom tabs that are available for us to
choose, and the Selected Tabs list shows us which tabs are already included, listed in the
order that they should be displayed. You'll notice that one tab, the Home tab, is already included
in our app by default. This is because the Home tab is required in every app, and must always
be in the first position; however, you can use the Default Landing Tab drop-down menu
to select which tab is first displayed when the app opens.
Again, since we're just creating a simple app, let's accept the defaults and move on. We'll add
more tabs later.
32
Building a Simple App
Now that we've defined some of the basic features of our app, you might be wondering what
remains to be done in the New Custom App wizard—shouldn't we already be done? It turns
out that one crucial step remains: we need to define the users who will be allowed to access
our app.
In this step of the New Custom App wizard, we can choose which user profiles should have
access to the app. We'll learn more about profiles in Securing and Sharing Data on page 127.
For now, just understand that every user is assigned to a profile, and profiles control which
apps the users assigned to that profile can view.
13. Select the Visible checkbox next to the Standard User and System Administrator
profiles.
14. Click Save.
That's it!
Tip: If you want to change the position of our app in this menu, do so from the Apps
list page by clicking Reorder and rearranging the available apps as you see fit.
Now select the Recruiting app from the menu and see what happens—our app is launched
with a single Home tab! We've created the Recruiting app's Home tab, and we've added it to
the Force.com app menu. That's how easy it is to get started.
You'll notice that the approach we're taking here is iterative: we'll build part of the app, look
at what we've accomplished, and then add to it. This sequence not only reflects the fact that
33
Chapter 4: Building a Simple App
we're leading you through the steps of building an app in this book, but you'll also find that
in building Force.com platform apps in general, this iterative process is common.
During the course of this book, you'll also notice that unlike with traditional coding projects,
your app is always functional. There's no build or compile phase, and as a result, you'll almost
never be chasing down syntax bugs or other typos. In fact, with this simple one-tab app, you
can already utilize all of the built-in functionality that comes with the platform, including
search, calendar events and tasks, user preferences, and a familiar user interface.
Introducing Objects
Now that our app is functional (but rather boring), let's make it a little more interesting by
introducing our first object.
As you might remember from the last chapter, an object is very similar to a database table in
the Force.com platform. The platform comes with a number of standard objects, like contacts,
accounts, and cases, which support default apps like Salesforce.com Sales and Salesforce.com
Call Center. We can also define custom objects that allow us to store information specific to
our Recruiting app.
Whether they're standard or custom, Force.com platform objects not only provide a structure
for storing data but they also power the interface elements that allow users to interact with the
data, such as tabs, the layout of fields on a page, and lists of related records. Because any object
can correspond to a tab, and an ordered collection of tabs makes up an app, objects make up
the heart of any app that we create with the platform.
With custom objects being so important—they have lots to do with how our app will look,
behave, and feel—what we do with custom objects and how we use them quickly becomes
essential to creating a successful app. The design of the data model behind an app is typically
the biggest factor in its success or failure.
That's enough talk about objects for now. Let's go define one!
34
Building a Simple App
location, and its hiring manager. In Force.com platform terms, we'll create a custom object,
create a custom tab for that object, and then define some custom fields.
Unlike defining a custom app, which we did through the New Custom App wizard, defining
a custom object is confined to just one page. You'll find that the platform uses wizards or single
pages depending on the amount of information that needs to be specified.
The Label and Plural Label of a custom object are what users see in all of the object's
related user interface elements, such as the object's tab or in search results headings. Object
labels work best as nouns, and the plural label is always used to label a custom object's tab (if
you create a tab for your object).
35
Chapter 4: Building a Simple App
The value of a custom object's Object Name represents the unique name for the object when
it's referenced in other areas of the platform, such as formulas and Visualforce pages. This
value is helpfully autogenerated based on the value that you enter for the Label, except that
all spaces and punctuation are replaced with underscore characters. We'll talk more about
formulas and Visualforce later in this book. For now, just keep in mind that the Object Name
value must be unique across all objects defined in your organization.
Note: Within the platform, Object Name is actually stored with __c appended to
the end as a suffix (for example, Position__c). This identifies it as a custom object.
The Record Name is the label for the field that identifies individual position records in the
system. A custom object cannot be saved without this identifying field.
The Data Type drop-down list allows you to select the type of value that should be used for
this identifying field: either Text or Auto-Number. Some objects, like Positions or Accounts,
can be identified with a text field because there will always be a name for a position or account
available. Other objects, like a Case (used in the standard Call Center app) are harder to identify
with a single text field, so we would assign them auto-numbers instead.
Tip: Whenever possible, it's best to use text as the data type for an identifying field
so that users can more easily identify a particular record when several of them appear
together in a single list.
To illustrate how custom object and record name labels work together in the app, let's fast
forward a bit to see where each label will appear once we've defined our Position custom object,
its tab, and a single Sr. Developer position record.
36
Building a Simple App
10. In the Optional Features area, select the Allow Reports, Allow Activities,
and Track Field History checkboxes.
In general, you should select these options if there's any chance that they might be useful for
whatever custom object you're defining.
12. In the Object Creation Options area, select the Add Notes & Attachments
related list to default page layout and Launch New Custom Tab
Wizard after saving this custom object checkboxes.
These two options are available only when you're creating a new custom object. If you later
decide to go back and edit some of the details about your custom object, you won't see them.
But what do they do?
• Enabling notes and attachments for an object means that you can attach external documents
to any position record, in much the same way that you can add a PDF or photo as an
attachment to an email. It's handy functionality, so you should generally select it.
• Launching the New Custom Tab wizard does exactly what it says—it's a shortcut to
launching the tab wizard after we've saved our Position object and will save us a few clicks
if we know that we need a tab.
All set? Let's go ahead and save our Position custom object now.
That's all there is to it! As promised, the New Position Tab wizard is displayed instead of the
list of custom objects that we'd normally see. Let's take a moment to talk about why we should
even be defining a tab for our Position object in the first place. What's so great about tabs,
anyway?
Introducing Tabs
If you're familiar with the Force.com platform, you know that clicking tabs is how you navigate
around an app. Every tab serves as the starting point for viewing, editing, and entering
information for a particular object. When you click a tab at the top of the page, the
corresponding home page for that object appears. For example, if you click the Accounts tab,
38
Building a Simple App
the Accounts tab home page appears, giving you access to all of the account records that are
defined in your organization. Click the name of a particular account record and you'll view all
of the record's information in its associated detail page.
What's really powerful about building an app with the platform is that you can create custom
tabs that look and behave just like the tabs for standard objects that are already provided. From
the perspective of your end users, any customizations that you make appear perfectly seamless,
and as a developer, you don't have to do anything special to make it work that way! Let's see
how quickly we can create a tab for our Position object.
Easy. Now that we're all on the same page, let's get started working through the wizard.
If you launched the wizard directly after defining the custom object, the Position object is
automatically selected for you.
4. Click the Tab Style lookup icon to launch the Tab Style Selector as shown in the
following screenshot.
Every object that appears as a tab must have a unique color scheme and icon. This color scheme
is what identifies the object, not only on its tab but also in different places in the user interface,
such as in related lists and search results.
39
Chapter 4: Building a Simple App
Figure 14: Custom Object Tab Setup Page and Tab Style Selector
In the Tab Style Selector, you can choose a predefined color and icon or you can create your
own. To keep things simple, we're going to select an existing style.
5. Click the Hide values which are used on other tabs link to make sure you choose
a unique style.
6. Click any colored box to choose a color scheme and icon.
Leave the Splash Page Custom Link drop-down list set to --None--. We'll learn more
about custom links in Moving Beyond Point-and-Click App Development on page 273.
7. In the Description field, enter A tab and color scheme for the
Position custom object.
8. Click Next.
9. Click Next again to accept the default user profile visibility.
Just as we controlled access to our Recruiting app by selecting user profiles in the New Custom
App wizard, we can also control access to our Positions tab by selecting user profiles here.
We'll learn more about user profiles and what they do in Securing and Sharing Data on page
127. For now, just know that accepting the defaults will make the tab visible to all users.
40
Building a Simple App
10. Deselect all of the Include Tab checkboxes except the one for our Recruiting app.
In performing this step, we're providing access to the Positions tab only when someone has
access to our Recruiting app. Unless an employee is interested in recruiting, he or she probably
doesn't need to see this tab.
If you don't select this option, any users who have personalized their tab display will not
immediately see the Positions tab. Also, if you've already created a new tab and didn't turn
this option on, you have to first delete the existing tab and then recreate it with this option
turned on to automatically push the tab to existing users. What a pain! Do yourself a favor and
just always keep this option selected.
You'll notice when the page refreshes that the Positions tab has automatically been added next
to the Home tab at the top of the page.
1. First, click the Positions tab to display the Positions tab home page, as shown in the
following screenshot. Although the list is empty because we haven't yet created any
records, you can see how this page will become the gateway to viewing, creating,
editing, and deleting all of the positions that we create in our Recruiting app. It looks
just like the tab home page of any other standard object.
41
Chapter 4: Building a Simple App
2. Now, check out the contents of the Create New... drop-down list in the left sidebar.
As promised, our custom object has been seamlessly incorporated into the platform
with the other standard objects like Event and Task. An end user need never know
that the Positions tab was created with a custom object, because it shows up alongside
the standard objects as well.
3. Select Position from the Create New... drop-down list, or click New in the Positions
tab home page. Voilà—it's the Position edit page! Sadly, though, our position still
doesn't have much room for data. At this point, all we have is a field for Position
Title (the record identifier) and Owner, a default field that appears on every object
to identify the user who created the object.
4. Click Cancel. It doesn't do to create a position record with hardly any interesting
data. We need more fields! And sure enough, that's what we'll get to next. First,
though, let's revisit our Position custom object and orient ourselves to what else is
available through a custom object detail page in the Setup area.
42
Building a Simple App
tab) when we created our Position object. If fields and user interface elements are a part of the
definition of what a custom object is all about, where do we get to define them?
It turns out that the Force.com platform differentiates between the initial creation of certain
components and details related to those components. In other words, the information that we
see when we define or edit a custom object is different from the information that we see when
we view a custom object that's already defined. Let's go back to our custom object list page to
see how this difference is reflected in the platform interface:
Here we are back in the custom object list page. You'll notice in the row for Position there are
three links that we can click:
Edit
This link takes us back to the Custom Object edit page where we originally
defined our Position object.
Del
This link deletes the custom object, including any records, tabs, reports,
or other components associated with that object.
Position
This link takes us to the custom object detail page for our Position object.
Figure 16: Custom Object List Page: Edit, Delete, and Detail Links
We're already familiar with the edit page from when we defined our Position object, and we
certainly don't want to delete our object. Let's go ahead and open up the detail page to see
what we can do there.
2. Click Position.
43
Chapter 4: Building a Simple App
As you can see, the Custom Object edit page that we filled out when we defined our Position
object was just the tip of the iceberg. The top two areas of the Position detail page (see Position
Custom Object Detail Page on page 28) include all of the information that we originally
specified, plus a few standard fields that the platform includes with every object. Below those
areas are several additional groupings of data that allow us to do more with our Position object.
In Force.com platform terms, those groupings of data are called related lists, and they're a big
part of what makes the platform so powerful. A related list is a list of records or other
components that are associated with whatever we're viewing. Related lists appear in both the
main application and in the Setup areas and represent a relationship between the items that
appear in the related list and the object or record that we're viewing in the detail area. We'll
learn a lot more about relationships in Expanding the Simple App Using Relationships on
page 83, but for now, just understand that anything that appears in an object's related list is
directly related to that object.
Now that we've found out where we can continue customizing our Position custom object,
let's use the Custom Fields & Relationships related lists to create some more fields in our
Position object.
44
Building a Simple App
Introducing Fields
We're ready to add more fields to our Position custom object, but first, let's talk briefly about
what a field is and how it fits into the world of the Force.com platform.
As you might remember from the last chapter, a field is like a database column. The primary
characteristic of a field is its data type—some fields hold text values, while others hold currency
values, percentages, phone numbers, email addresses, or dates. Some fields look like checkboxes,
while still others are drop-down lists or record lookups from which a user makes a selection.
The data type of a field controls the way the field is ultimately displayed in the user interface
and how data entered into the field is stored in the platform. To get a better feel for how the
fields will look, let's take a sneak peak at what the Position object is ultimately going to look
like and the types of custom fields we're going to create for it:
45
Chapter 4: Building a Simple App
There are a lot of fields here that we need to define, some more complicated than others. To
keep things simple, let's go through and create the simple text, currency, checkbox, and date
fields. We can tackle the more complicated picklist and custom formula fields in Enhancing
the Simple App with Advanced Fields, Data Validation, and Page Layouts on page 52.
46
Building a Simple App
2. Click Position.
3. In the Custom Fields & Relationships related list, click New.
Every time you create a custom field, you'll first choose a data type from the field type selection
page.
• Basic text fields allow users to enter any combination of letters and numbers on a single
line, up to as many as 255 characters.
• Text area fields also have a 255 character limit but also allow carriage returns so the text
can be formatted on separate lines.
• Long text fields allow as many as 32,000 characters, on separate lines.
Since job descriptions can be lengthy, let's choose a long text area.
4. Choose the Text Area (Long) data type and click Next.
Tip: Carefully consider the data type you choose for each of your custom fields, because
once you set it, it isn't always the best idea to change it later. See Notes on Changing
Custom Field Types in the online help for details.
The second page of the custom field wizard allows us to enter details about our long text area
field. The fields that appear in this step change depending on the data type that we selected
in the previous page.
Like the other labels that we've seen in the platform so far, the Field Label specifies the
text that should be displayed to users when the field is rendered in the user interface. Notice
that when we enter a value for Field Label, Field Name is automatically populated with
the same text but with all spaces and punctuation replaced by underscores. The value for Field
Name is a unique name that is used to refer to the field when writing a custom formula or using
the API.
Note: Within the platform, Field Name is actually stored with __c appended to
the end as a suffix (for example, Job_Description__c). This identifies it as a
custom field.
The Length field allows us to restrict the maximum number of characters that are allowed.
Since we don't get any benefit from this kind of restriction, leave this value set to 32,000.
This field allows us to specify how large our text box will appear on the page.
This help text is displayed on record detail and edit pages when users hover over the field's
label. Its purpose is to assist users in filling out the field correctly. It's optional to add help text
for a field, but it's a good idea if you have fields that you think users might be confused by.
There's no obvious default value for a text field, so just leave Default Value blank.
9. Click Next.
The third page of the Custom Field wizard allows us to restrict access to this field from certain
user profiles. We'll learn more about profiles and field-level security in Securing and Sharing
Data on page 127, so for now, just accept the defaults.
The last page of the wizard allows us to automatically place our field on the Position page
layout. Again, we'll learn about page layouts in the next chapter, so for now, just accept the
defaults.
Instead of clicking Save and returning to the Position object detail page, clicking Save & New
saves a few clicks and allows us to finish up the other text area fields that we need. Here's what
you need to know to define them:
Now that we've wet our feet with text fields, let's quickly create a few more fields of other
types. You'll find that with few exceptions, they're all very similar to one another.
48
Building a Simple App
Defining a currency field is almost identical to defining a text field, with a few slight differences:
• The Length of a currency field actually corresponds to the number of digits to the left of
the decimal point. An additional Decimal Places field handles the number of digits
that should be displayed to the right.
• In the Details page of the wizard, a new checkbox called Required is displayed. We can
select this option if we want to force our users to enter a value for this field when creating
a new position.
Everything else should be familiar to you, so go ahead and use the custom field wizard to define
the following fields:
49
Chapter 4: Building a Simple App
Once again we'll use the custom field wizard to define these three fields:
50
Building a Simple App
Check out all the fields we've just made! It's not the most elegant layout for all of our fields
(each field got added to the page in the order that we created it), but it's definitely functional,
and it looks just like any other page. Wasn't that easy?
Once again, welcome to the power of the Force.com platform. First we created a new recruiting
app with a single Home tab, then we created a Position object and tab, and now we've just
added a few fields, all in less than 15 minutes of clicking around. From start to finish we always
had a fully functional app, and we never had to spend any time compiling or debugging our
“code!”
In the next chapter, we'll enhance our simple Recruiting app even further by adding some
additional fields that are more complex, defining validation rules to help our data stay clean,
and then moving the fields around in a page layout so users can more easily find and enter the
information they need. Let's keep going!
51
Chapter 5: Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
Chapter 5
Enhancing the Simple App with Advanced Fields,
Data Validation, and Page Layouts
In this chapter ... In the last chapter, we got our Recruiting app off to a quick
start by defining the Position custom object, tab, and several
• Adding Advanced Fields simple fields. This simple version of our app had the same
• Introducing Validation look and feel as any other page on the Force.com platform,
Rules and we were able to whip it together in a matter of minutes.
• Introducing Page Layouts
In this chapter, we're going to enhance the Positions tab:
first by defining a few more advanced fields, then by defining
a validation rule to make sure our data stays clean, and finally
by moving our fields around within a page layout. These
additions will help change the detail page of our Positions
tab from a somewhat flat and inelegant user interface to
something that users find powerful and intuitive to use. Let's
get started!
52
Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
Introducing Picklists
When viewing the preview of what we wanted our Positions page to ultimately look like, there
were several fields that were specified with drop-down lists. In Force.com platform terms,
these fields are called picklists, and they consist of several predefined options from which a user
can select.
Picklists come in two flavors: a standard picklist, in which a user can select only one option,
and a multi-select picklist, in which a user can select multiple options at a time. For the purposes
of our Position object, we need to define standard picklists for a position's location, status,
type of job, functional area, and job level.
53
Chapter 5: Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
2. Click Position.
3. In the Custom Fields & Relationships related list, click New.
4. Select the Picklist data type and click Next.
5. In the Field Label text box, enter Location.
6. In the large text area box just below, enter the following picklist values, each on its
own line:
• San Francisco, CA
• Austin, TX
• Boulder, CO
• London, England
• New York, NY
• Mumbai, India
• Sydney, Australia
• Tokyo, Japan
This option allows us to populate the field with a default value. If you leave it deselected, the
field defaults to None on all new position records. Otherwise the field defaults to the first value
that you specify in the list of possible picklist values. Because most positions at Universal
Containers are based at its headquarters in San Francisco, CA, this should be the default.
8. Accept all other default settings for field-level security and page layouts.
9. Click Save & New.
Easy! Now specify the remaining picklists according to the table below:
Table 6: Status, Type, Functional Area, and Job Level Picklist Values
Data Type Field Label Picklist Values Sort Use First Value
Alphabetically? as Default?
Picklist Status New Position No Yes
Pending
Approval
Open -
Approved
Closed - Filled
54
Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
Data Type Field Label Picklist Values Sort Use First Value
Alphabetically? as Default?
Closed - Not
Approved
Closed -
Canceled
Internship
Contractor
Information
Technology
Retail Operations
Warehousing
Miscellaneous
FN-200
FN-300
FN-400
HR-100
HR-200
HR-300
55
Chapter 5: Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
Data Type Field Label Picklist Values Sort Use First Value
Alphabetically? as Default?
HR-400
IT-100
IT-200
IT-300
IT-400
RO-100
RO-200
RO-300
RO-400
WH-100
WH-200
WH-300
WH-400
MC-100
MC-200
MC-300
MC-400
56
Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
list. That meant that you had to scroll all the way down to the countries that started with the
letter U. What a pain!
Fortunately, the folks who built the Force.com platform have encountered that situation a few
times themselves, and as a result, they've given us a tool to help us avoid this problem with our
own picklist fields: field dependencies.
Field dependencies are filters that allow us to change the contents of a picklist based on the
value of another field. For example, rather than displaying every value for Country in a single
picklist, we can limit the values that are displayed based on a value for another field, like
Continent. That way our users can find the appropriate country more quickly and easily.
Picklist fields can be either controlling or dependent fields. A controlling field controls the
available values in one or more corresponding dependent fields. A dependent field displays
values based on the value selected in its corresponding controlling field. In the previous example,
the Continent picklist is the controlling field, while the Country picklist is the dependent field.
A field dependency matrix displays with all the values in the controlling field across the top
header row and the dependent field values listed in the columns below. For each possible value
of the controlling field, we need to include the values that should be displayed in the dependent
picklist when that controlling value is selected. In the field dependency matrix, yellow
highlighting shows which dependent field values are included in the picklist for a particular
controlling field value.
57
Chapter 5: Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
To include a dependent field value, you simply double-click it. To exclude a dependent value
from the list, double-click it again.
For example, let's try it out by including the values that should be displayed in the Job Level
picklist whenever Finance is selected in the Functional Area picklist:
8. In the column labeled Finance, double-click FN-100, FN-200, FN-300, and FN-400.
Those four fields should now be shaded yellow in the Finance column.
Instead of double-clicking every Job Level value, we can also use SHIFT+click to select a
range of values or CTRL+click to select multiple values at once. Once those values are
highlighted in blue, we can click Include Values to include them, or Exclude Values to remove
them. Let's try it out.
9. In the column labeled Human Resources, single-click HR-100 and then press and
hold the SHIFT key while clicking HR-400.
10. Click Include Values.
Now we have values selected for both the Finance and Human Resources columns!
58
Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
11. Continue highlighting the appropriate values for all of the remaining columns, as
described in the following table.
Tip: To get to all of the values that you need to modify for this step, you'll need to
click Previous or Next to see additional columns.
Finance • FN-100
• FN-200
• FN-300
• FN-400
Warehousing • WH-100
• WH-200
• WH-300
• WH-400
Miscellaneous • MC-100
• MC-200
59
Chapter 5: Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
• MC-300
• MC-400
Our Recruiting app users are going to be very happy that they no longer have to deal with a
long, onerous picklist. Now let's go add a field that's even more powerful and complex than a
dependent picklist: a custom formula field.
60
Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
Fortunately, custom formula fields give us the ability to do just that. Just as you can use a
spreadsheet program like Microsoft Excel to define calculations and metrics specific to your
business, we can use custom formula fields to define calculations and metrics that are specific
to our Recruiting app.
For example, on our Position object, we've already created fields for minimum pay and maximum
pay. If Universal Containers gives out yearly bonuses based on salary, we could create a custom
formula field that automatically calculated the average bonus that someone hired to that position
might receive.
How would we perform this calculation if we were using a spreadsheet? The columns in our
spreadsheet would represent the fields that we defined on our Position object, and each row
of the spreadsheet would represent a different position record. To create a calculation, we'd
enter a formula in a new column that averages the values of Min Pay and Max Pay in a single
row and then multiplies it by a standard bonus percentage. We could then determine the
average bonus for every position record row in our spreadsheet.
Custom formulas work in a very similar way. Think of a custom formula like a spreadsheet
formula that can reference other values in the same data record, perform calculations on them,
and return a result. However, instead of using cell references, you use merge fields, which serve
as placeholders for data that will be replaced with information from your records, user
information, or company information. And, instead of typing fields, operators, and functions,
you can click to select them.
The net result is that anyone can quickly and easily learn to create formula fields. And, as with
all platform tools, the cloud computing delivery model makes it easy to experiment. You can
create a formula, view the results, and change the formula again and again, as many times as
you want! Your underlying data is never affected.
Tip: When defining your own custom formula fields, leverage the work of others.
You can find more than a hundred sample formulas on the Salesforce.com Community
website at http://www.salesforce.com/community/.
Let's think about the data that we need to make this calculation: we need to know the current
date and the date that the position was created. If we could somehow subtract these two, we'd
61
Chapter 5: Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
have the number of days that the position has been open. Fortunately, it's easy to get both of
these values:
• For the current date, we can simply use the platform's built-in TODAY() function. TODAY()
returns today's date.
• For the date that the position was opened, we can use the Open Date field that we defined
in the last chapter.
When using fields in formulas, you can't just refer to a field by its name. Instead, you need to
refer to it by its merge field name, also called its API name. The format of the API name is
typically the name of the field but with spaces instead of underscores. For custom fields, the
API name is suffixed with two underscores and the letter “c,” like this: Open_Date__c. This
naming convention in the platform helps distinguish between standard and custom fields.
Tip: You don't need memorize the API names of fields you want to use in formulas.
Simply use the field picker in the formula editor to insert fields and the platform
automatically inserts the API name for you. If you ever want to know the API name
of a specific field and you aren't using the formula editor, you can view the field's detail
page.
Now that we have our two dates, we want to subtract them: TODAY() - Open_Date__c.
Even if the two dates span different months or years, the platform is sophisticated enough to
know how to handle all the intricacies of such a calculation behind the scenes. We just have
to provide the dates, and the platform can do all the rest.
So far so good, but one problem still remains—what if the position has already closed? Our
formula only works if we assume the position is still open. Once it closes, however, the value
of our current formula will keep incrementing every day as TODAY() gets farther and farther
away from the original Open Date. If we can, we want to use the Close Date field in the
formula instead of TODAY() after a position closes. How can we do this?
Once again, all we need to do is dip into the extensive library of platform functions. The IF()
function allows us to perform a test and then return different values depending on whether
the result of the test is true or false. The IF() function's syntax looks like this:
IF(logical_test,
value_if_true,
value_if_false)
For the logical_test portion, we'll test whether the Close Date field has a value—if it
does, the position obviously must be closed. We'll test for this with a third built-in function:
62
Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
ISBLANK(). ISBLANK() takes a single field and returns true if it does not contain a value
and false if it does. So now our formula looks like this:
By replacing value_if_true and value_if_false with the other formulas we talked about,
we've now figured out our whole formula:
Great! Our formula calculates the number of days a position has been open, regardless of
whether it's currently open or closed. Now, let's go define a field for it on our Position object.
63
Chapter 5: Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
In this case, even though we're subtracting Date fields, we want to end up with just a regular
numeric value.
64
Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
We want to use the Advanced Formula tab so we can access the platform's built-in functions
through the Functions list on the right side.
10. Delete logical_test from the formula, but leave your cursor there.
11. From the Functions list, double-click ISBLANK.
12. Delete expression from the ISBLANK function you just inserted, but leave your
cursor there.
13. Click the Insert Field button. Two columns appear in an overlay.
14. In the left column, select Position.
15. In the right column, select Close Date.
16. Click Insert.
Did you notice that you didn't have to remember to use the API name of the Close Date
field? The platform remembered for you when it inserted the value. Our formula now looks
like this:
65
Chapter 5: Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
Now, let's specify the value if our logical test evaluates to true:
17. Delete value_if_true from the formula, but leave your cursor there.
18. Press Enter on your keyboard, and space over 10 spaces.
Adding the carriage return and spaces makes our formula more legible for others.
Finally, let's specify the value if our logical test evaluates to false:
25. Delete value_if_false from the formula, but leave your cursor there.
26. Press Enter on your keyboard, and space over 10 spaces.
27. Click the Insert Field button.
28. In the left column, select Position.
29. In the right column, select Close Date and click Insert.
30. Click Insert Operator and choose Subtract.
31. Click the Insert Field button.
32. In the left column, select Position.
33. In the right column, select Open Date and click Insert.
Now that we've gone through those steps of the procedure, note that we could have just typed
in the formula that we figured out in the last section. However, using the formula editor is a
lot easier because you don't have to remember function syntax or API names of fields and
objects. Let's keep going and finish up this field:
66
Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
35. In the Description text box, enter The number of days a position
has been (or was) open.
36. Add an optional Help Text description if you wish.
37. Select Treat blank fields as blanks, and click Next.
38. Accept all remaining field-level security and page layout defaults.
39. Click Save.
Look familiar? This is similar to the editor that we used to define our Days Open custom
formula field.
TODAY() + 90
8. Click Save.
It's that easy! Now to wrap up the fields on our Positions tab, let's set the default value of the
Open Date field to the day that the record is created. To do this, follow these steps again,
but use TODAY() as the Default Value.
67
Chapter 5: Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
In order to see our Days Open field, we'll have to define our first position record. Let's do
that now.
3. Enter any values you want to define a new position. At the very least, you must enter
a value for the required Position Title field.
4. Click Save.
The new position is now displayed in its own record detail page. At the bottom of the page,
notice our Days Open formula field, just above the Created By field. It should show 0,
since we just created the position. If you want to see the value change, edit the record and set
the Open Date to a week earlier. Isn't that neat?
For example, does it ever make sense for the value of the Min Pay field to be more than the
value of the Max Pay field? Or should Close Date ever be unspecified if the Status field
is set to Closed - Filled or Closed - Not Approved? Clearly not. We can catch these sorts of
errors in our app with yet another built-in feature of the platform: validation rules.
Validation rules verify that the data a user enters in your app meets the standards that you
specify. If it doesn't, the validation rule prevents the record from being saved, and the user sees
an error message that you define either next to the problematic field or at the top of the edit
page. Let's build a couple of validation rules now for our Recruiting app.
68
Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
Note: You can find dozens of sample validation rules on the Salesforce.com
Community website at http://www.salesforce.com/community.
Try It Out: Defining a Validation Rule for Min and Max Pay
For our first validation rule, let's start off simple: Min Pay should never be greater than Max
Pay:
The name of a validation rule can't include any spaces, but if you forget, the platform helpfully
changes them to underscores (_) for you.
69
Chapter 5: Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
This checkbox specifies whether the validation rule should start working as soon as it's saved.
Because this rule is pretty straightforward (and because we want to test it later!), it makes sense
to turn it on right away.
6. In the Description text box, enter Min Pay should never exceed Max
Pay.
Now it's time to define the meat of our validation rule: the error condition. If you have a sense
of déjà vu when looking at the Error Condition Formula area of the page, don't be alarmed!
Just like formula fields and default field values, a validation rule can leverage a number of
built-in operators and functions to define a true-or-false error condition that determines
whether data is valid. When this condition evaluates to true, an error message displays and the
record can't be saved.
We want our error condition to be true whenever Min Pay is greater than Max Pay, so let's
use our formula editor to specify that now:
7. Click the Insert Field button. Just like in the formula field editor, two columns
appear in an overlay.
8. In the left column, select Position.
9. In the right column, select Min Pay.
10. Click Insert.
11. Click the Insert Operator button, and choose Greater Than.
12. Click the Insert Field button once again.
13. In the left column, select Position.
14. In the right column, select Max Pay.
15. Click Insert.
You should now have an error condition formula that looks like this:
Now the only thing that remains is to specify the error message when our error condition
evaluates to true.
16. In the Error Message text box, enter Min Pay cannot exceed Max Pay.
17. Next to the Error Location field, select the Top of Page radio button.
Tip: If a rule requires a user to review the values of multiple fields, it's more appropriate
to place the error message at the top of the page because you don't know which field
the user needs to change.
70
Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
Easy! Now that we've familiarized ourselves with a simple validation rule, let's define one that's
a little trickier.
The hardest part of this validation rule is defining the error condition formula. When defining
a condition like this, it's sometimes easiest to think about it in logical terms first, and then
translate that logic to the functions and operators that are provided in the formula editor. In
this case, our error condition is true whenever:
AND
Let's start with the first piece: “Close Date is Not Specified.” To translate this into terms the
formula editor understands, we'll need to use the ISBLANK() function again. As you might
remember from defining the Days Open custom formula field, ISBLANK() takes a single
field or expression and returns true if it doesn't contain a value. So, remembering that we have
to use the internal field name of the Close Date field in our formula, Close Date is
Not Specified translates to:
ISBLANK( Close_Date__c )
Next, let's figure out how to translate “Status is 'Closed - Filled'.” To test for picklist values,
we'll need to use another function: ISPICKVAL(). ISPICKVAL() takes a picklist field name
and value, and returns true whenever that value is selected. So “Status is 'Closed - Filled'”
translates to:
Tip: When working with picklists in formulas, convert them to text using either the
ISPICKVAL() function or the TEXT() function. For example, to check the value of
a picklist using the TEXT() function, use TEXT(Status__c) = “Closed -
Filled”.
71
Chapter 5: Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
Now we just have to combine these translations, which we can do using a mix of the AND()
and OR() functions. Both functions evaluate an unlimited number of expressions, but AND()
returns true if all of the expressions are true while OR() returns true if any of the expressions
are true. For example:
returns true when exp1, exp2, and exp3 are all true. Likewise,
returns true when any one of exp1, exp2, or exp3 are true.
Put these functions all together with our other expression translations, and we get our completed
error condition formula:
AND (
ISBLANK( Close_Date__c ),
OR (
ISPICKVAL( Status__c , "Closed - Filled"),
ISPICKVAL( Status__c , "Closed - Not Approved"))
)
Phew! Now we can quickly define our second validation rule using this formula:
8. Click Check Syntax to make sure the format of the formula is correct.
9. In the Error Message text box, enter Close Date must be specified
when Status is set to 'Closed.'
72
Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
10. Next to the Error Location field, select the Field radio button, and then choose
Close Date from the drop-down list.
11. Click Save.
First let's try defining a new position with a value for Min Pay that's larger than Max Pay.
Did you see what happened? Your custom error message popped exactly like any other error
message in the app!
73
Chapter 5: Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
Our second validation rule is triggered, this time because we didn't specify a value for Close
Date. Once we do, the record saves normally.
The Positions tab is now fully functional, with a couple of validation rules to ensure that users
don't make certain mistakes. But are the fields where we want them? Are the fields that must
74
Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
have values marked as required? In the next section, we'll fine-tune our Position custom object
by modifying its page layout.
A page layout controls the position and organization of the fields and related lists that are visible
to users when viewing a record. Page layouts also help us control the visibility and editability
of the fields on a record. We can set fields as read-only or hidden, and we can also control
which fields require users to enter a value and which don't.
Page layouts are powerful tools for creating a good experience for our users, but it's crucial that
we remember one important rule: page layouts should never be used to restrict access to sensitive
data that a user shouldn't view or edit. Although we can hide a field from a page layout, users
can still access that field through other parts of the app, such as in reports or via the API.
(We'll learn more about security that covers all parts of the app in Securing and Sharing Data
on page 127.)
Now let's see if we can organize the fields on our Position object in a way that's more user
friendly.
The enhanced page layout editor provides all of the same functionality as the original editor,
but with additional enhancements, including an intuitive WYSIWYG interface and the ability
to customize the space between fields in your layouts. Since the enhanced page layout editor
is enabled by default, it's the one we'll use to edit page layouts in this book.
Note: The enhanced page layout editor doesn't work with some older browsers. If
you don't want to upgrade your browser, you can always switch to the original page
layout editor by clicking Your Name ➤ Setup ➤ Customize ➤ User Interface and
deselecting the Enable Enhanced Page Layout Editor; however, if you use
the original page layout editor, what you see on your screen will not match the
75
Chapter 5: Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
procedures in this book, and you won't be able to customize the space between fields
in your layouts.
Let's try using the page layout editor to edit the page layout of the Position object:
Welcome to the page layout editor! As you can see, this editor is different from the ones that
we've already used in other areas of the platform. That's because we're designing a user interface
and need to see how our page will look as we're working. Before going any further, let's give
ourselves a quick orientation to how this page is set up.
The page layout editor consists of a palette at the top of the screen and the page layout below
it. The palette contains the user interface elements that are available for you to add to the page
layout, including fields, buttons, links, and related lists. To add one of these user interface
elements to the page layout, simply select the category to which the element belongs on the
left column of the palette and drag the element from the palette to the page layout. To remove
a user interface element from the page layout, drag the element from the page layout to the
76
Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
right side of the palette, or click the X ( ) icon that appears when you hover over the field. A
toolbar above the palette provides various functions, such as saving and previewing your changes.
Now that we know what we're looking at, let's rearrange the fields in the way a user might
want to see them.
When you drag a new section on to the page layout, the Section Properties popup window
appears.
The Section Name field controls the text that's displayed as the heading for the section.
4. In the Display Section Header On area, select both the Detail Page and Edit
Page checkboxes.
Displaying the header on both the detail and edit pages helps users understand the context of
the information, regardless of whether they are editing the position or just viewing it.
This option allows us to choose whether we want the fields in our section to be arranged in
two columns or one. The default is two columns and is the most commonly-used choice.
However, if our section is going to contain text area fields, the one-column layout gives them
more space on the page for display.
This setting controls the direction that a user's cursor will move when using the Tab key to
navigate from field to field.
7. Click OK.
77
Chapter 5: Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
We have a new section for Compensation just above the System Information section! Let's
add the Min Pay and Max Pay fields:
8. While pressing the CTRL key, click both the Min Pay and Max Pay fields in the
System Information section, and drag them to the new Compensation section as
shown in the following screenshot.
Pressing the CTRL key allows you to select multiple individual user interface elements with
your mouse. Alternatively, pressing the SHIFT key allows you to select a group of elements.
Now that we've gone through the process for building one section, let's build two more. As
we do this, you might have to scroll up and down to view the entire layout, depending on the
size of your screen. Rest assured that if you have to scroll, the palette will move with you,
making it easy to add user interface elements even at the very bottom of the page layout.
9. Create a new one-column Description section below the Compensation section, and
drag Job Description, Responsibilities, Skills Required, and
Educational Requirements into it.
10. Create a new two-column Required Languages section below the Description section,
and drag Apex, C#, Java, and JavaScript into it.
As you work, you may notice that the fields you add to the page layout are grayed-out in the
palette, but the Section user interface element is never grayed-out. This is because fields can
only appear one time on each page layout, but the Section user interface element can be reused
to create as many sections as you want.
78
Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
Tip: If you make a mistake while editing the page layout, you can use CTRL+Z and
CTRL+Y to undo and redo your recent moves, respectively. The toolbar contains
Redo and Undo buttons as well.
While we're shuffling fields around, let's reorganize the Information section so it's more
readable.
• Position Title
• Status
• Type
• Functional Area
• Job Level
• Travel Required
• Created By
• Owner
• Location
• Open Date
• Hire By
• Close Date
• Days Open
• Last Modified By
That's much better—our fields are organized, and it's easy to locate all of the information we
need.
The Information section still looks a little dense, though. Fortunately, the page layout editor
provides a way to add blank spaces that separate the fields within the section to improve its
readability even further.
Created By and Last Modified By fields from the critical position information. Let's
give it a try!
13. Select any category in the palette except for Related Lists and Buttons.
14. Drag the Blank Space user interface element from the palette to the page layout right
below the Position Title field.
As with the Section user interface element, the Blank Space user interface element is never
grayed-out in the palette when you drag it to the page layout because the element can be reused
as many times as you want.
15. On the palette, select the Blank Space user interface element again and drag it below
the Owner field.
16. Add two more blank spaces to the page layout, one above the Created By field
and the other above the Last Modified By field.
Before we move on, you should be aware that if you accidentally navigate away from the page
layout before saving your work, your changes will be lost. Rather than tempting fate, let's do
a quick save of the work that we've done so far.
17. Click Quick Save in the toolbar above the palette, or press CTRL+S if you prefer
using keyboard shortcuts.
The quick save feature allows you to save your changes and continue editing the page layout.
Clicking Save in the toolbar also saves your work, but it takes you back to the page from which
you accessed the page layout editor. We have a few more minor tweaks to make to our page
layout, so we don't want to leave the page layout editor just yet.
• If it's required, a user won't be able to create a position record without specifying a value.
80
Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
• If it's read-only, a user who views a position record edit page won't be able to change its
value.
Required fields are denoted with a red asterisk ( ), while read-only fields are denoted with
a lock icon ( ).
Caution: Although we can make these changes on the page layout, don't forget our
earlier warning! Page layouts should never be used as the sole means to restrict access
to sensitive data that a user shouldn't view or edit. That's because page layouts control
only a record's edit and detail pages; they don't control access to those fields in any
other part of the platform.
At this point, we don't have any fields that need to be read-only, but we do want to make sure
that the salary range is always defined for each position, so let's make the Min Pay and Max
Pay fields required. Once we do that, we'll be all done with our Position object!
To make the Min Pay and Max Pay fields required, we need to edit the properties of each
field:
1. In the page layout editor, double-click the Min Pay field, or select the wrench icon
( ) next to the field name.
This popup window allows us to edit the Min Pay field's properties. We can set the field to
read-only and/or required. If we didn't want a user to see the Min Pay field at all, we could
simply drag it off the layout and onto the palette. We want to make sure it stays visible for
right now, so let's leave it in its current spot.
Hooray! We're all done with our Position object's page layout.
81
Chapter 5: Enhancing the Simple App with Advanced Fields, Data Validation, and Page Layouts
We have an object with a tab, we've added custom fields, and we've arranged them in a page
layout. We've finished our simple app, and now we're well on our way to creating the more
complex Recruiting app that we described earlier.
Things are going to get even more interesting in the next chapter. We'll add a few more custom
objects to track things like candidates, job applications, and reviews, and then we'll enhance
our Recruiting app even further by defining how our objects relate to one another. Before you
know it, we're going to have an incredibly powerful Web application, all implemented with a
few clicks in the platform.
82
Chapter 6
Expanding the Simple App Using Relationships
In this chapter ... So far we've accomplished a fair amount—we've created the
Recruiting app and built out a fully functional Position
• Introducing Relationships custom object with a tab and several types of fields. It's a
• Introducing Relationship good start, but there's more to do.
Custom Fields
• Adding Candidates to the Having just one object in our Recruiting app is like having
a party with just one guest—not all that interesting! We
Mix
need to invite more “people” to the party by building custom
• Bringing Candidates and objects to represent candidates, job applications, and reviews,
Positions Together with and, even more importantly, we need to create relationships
Job Applications between them. Just like a party isn't all that fun if you don't
• Introducing Search know any of the other guests, an app isn't all that powerful
Layouts unless its objects have links to other objects in the app. That's
• Managing Review going to be the focus of this chapter, so let's get started!
Assessments
• Creating a Many-to-Many
Relationship
• Putting it All Together
83
Chapter 6: Expanding the Simple App Using Relationships
Introducing Relationships
So what is a relationship, and why are they important for our app? Just as a personal relationship
is a two-way association between two people, in terms of relational data, a relationship is a
two-way association between two objects. Without relationships, we could build out as many
custom objects as we could think of, but they'd have no way of linking to one another.
For example, after building a Position object and a Job Application object, we could have lots
of information about a particular position and lots of information about a particular candidate
who's submitted an application for it, but there would be no way of seeing information about
the job application when looking at the position record, and no way of seeing information
about the position when looking at the job application record. That's just not right!
With relationships, we can make that connection and display data about other related object
records on a particular record's detail page. For example, once we define a relationship between
the Position and Job Application objects we just talked about, our position record can have a
related list of all the job applications for candidates who have applied for the position, while a
job application record can have a link to the positions for which that candidate is applying.
Suddenly the “people” at our Recruiting app “party” know some of the other guests, and the
app just got a lot more interesting.
Figure 31: Relationships Allow Information about Other Object Records to be Displayed
on a Record Detail Page
84
Expanding the Simple App Using Relationships
There are different types of relationship fields, each with different implications. The simplest
and most flexible type is a lookup relationship field, which creates a simple relationship between
two objects. For example, if we place a lookup relationship field on a Job Application object
that references position records, many job application records can be related to a single position
record. This will be reflected both with a new Position field on the job application record
and with a new Job Applications related list on the position record. You can also put multiple
lookup relationship fields on a single object, which means that our Job Application object can
also point to a Candidate object.
A second type of relationship field, master-detail relationship, is a bit more complex, but more
powerful. Master-detail relationships create a special parent-child relationship between objects:
the object on which you create the master-detail relationship field is the child or “detail,” and
the object referenced in the field is the parent or “master.” In a master-detail relationship, the
ownership and sharing of detail records are determined by the master record, and when you
delete the master record, all of its detail records are automatically deleted along with it.
Master-detail relationship fields are always required on detail records, and once you set a
master-detail relationship field's value, you cannot change it.
When do you use a master-detail relationship? If you have an object that derives its significance
from another object. For example, say you have a Review custom object that contains an
interviewer's feedback on a job application. If you delete a job application record, you will
probably want all of its review records deleted as well, being that reviews of something that no
longer exists aren't very useful. In this case, you want to create a master-detail relationship on
the Review custom object with the Job Application object as the master object.
That's the sort of thing that we're going to do in this chapter. First, let's start with the really
quick and easy example of putting a Hiring Manager field on our Position object—we'll
create a many-to-one relationship between the Position object and the standard User object
that comes with every organization, reflecting the fact that a hiring manager can be responsible
for several positions at a time. Then we'll build out a few more objects and implement a more
complex relationship involving positions, job applications, candidates, and reviews.
85
Chapter 6: Expanding the Simple App Using Relationships
For example, if Ben Stuart, our recruiter, wants to assign Anastasia O'Toole as the hiring
manager for the Benefits Specialist position, he'll be able to do so by clicking the lookup icon
( ) next to the lookup relationship field that we are going to create. Her name will then appear
on the Position detail page.
To create the lookup relationship field that accomplishes this, we'll need to go back to the now
familiar Position object detail page.
As we've mentioned, User is a standard object that comes with all organizations on the platform.
It contains information about everyone who uses the app in your organization.
6. In the Field Label text box, enter Hiring Manager. Once you move your
cursor, the Field Name text box should be automatically populated with
Hiring_Manager.
7. Click Next.
8. Accept the defaults in the remaining two steps of the wizard.
9. Click Save.
86
Expanding the Simple App Using Relationships
As you can see, it was easy to set up this simple relationship between positions and users. And
as a general rule, you'll find that relationships are pretty easy to set up.
What gets a little tricky is when we start wanting to create relationships that don't represent
a simple many-to-one relationship. We'll see an example of one of those in a little bit. Right
now, let's build a custom object for candidates so we'll be able to create some more relationships
in our Recruiting app.
87
Chapter 6: Expanding the Simple App Using Relationships
Field Value
Label Candidate
Plural Label Candidates
Object Name Candidate
Description Represents an applicant who might apply for
one or more positions
Context-Sensitive Help Setting Open the standard Salesforce.com Help &
Training window
Record Name Candidate Number
Data Type Auto Number
Display Format C-{00000}
Starting Number 00001
Allow Reports Yes
Allow Activities Yes
Track Field History Yes
Deployment Status Deployed
Add Notes & Attachments related list to Yes
default page layout
Launch New Custom Tab Wizard after saving Yes
this custom object
To create the Candidates tab, select a Tab Style in the first step of the wizard, and then
accept all the defaults until you get to the Add to Custom Apps page. On this page, select only
the Recruiting App and click Save.
The Recruiting app now has three tabs: Home, Positions, and Candidates. Now let's add some
custom fields to the Candidate object.
88
Expanding the Simple App Using Relationships
One difference you'll see in the Candidate object fields is that three of them—First Name,
Last Name, and Email—have the External ID option selected. This option allows the
values in these fields to be indexed for search from the sidebar of the application. If we didn't
select these values as external IDs, we'd only be able to search for records based on the
Candidate Number field. Setting the Email field as an external ID is also going to help us
with importing data a little later in this chapter.
Phone Phone
Email Email External ID: Selected
Text Street Length: 50
Text City Length: 50
Text State/Province Length: 50
Text Zip/Postal Code Length: 15
Text Country Length: 50
Text Current Employer Length: 50
Number Years of Experience Length: 2
Decimal Places: 0
89
Chapter 6: Expanding the Simple App Using Relationships
6. Click Save.
Your Candidate page layout should now look similar to the following screenshot.
90
Expanding the Simple App Using Relationships
How does the page layout look? Are the fields where you want them?
If you page layout doesn't look quite right and you need to make a few adjustments, click the
Edit Layout link in the upper right corner.
91
Chapter 6: Expanding the Simple App Using Relationships
The Edit Layout link takes you directly to the page layout editor and lets you modify the page
you are currently viewing.
If you are able to successfully create a new candidate record and everything looks okay, let's
move on to the Job Application object!
We can satisfy these requirements with a Job Application custom object that stores data about
an individual candidate's application to a single position. Each time a candidate wants to apply
for a position, the recruiter can create a job application record that contains the candidate's
name and the position to which he or she is applying, as well as any cover letter that the
candidate may have submitted specifically for that position. Recruiters will also be able to
indicate the status of the candidate's application, such as whether he or she is scheduled for
an interview or if the application has been rejected. After we create the Job Application object
and its fields, we'll make a few small modifications to the Position, Candidate, and Job
Application objects so that each position record displays the names of the candidates who have
92
Expanding the Simple App Using Relationships
applied to it, and each candidate record displays the name of the positions to which the candidate
has applied.
You should be a pro at this by now! To create our Job Application custom object, navigate
back to Your Name ➤ Setup ➤ Create ➤ Objects, click New Custom Object, and fill out
the page according to the following table.
Field Value
Label Job Application
Plural Label Job Applications
Object Name Job_Application
Description Represents a candidate's application to a
position
Context-Sensitive Help Setting Open the standard Salesforce.com Help &
Training window
Record Name Job Application Number
Data Type Auto Number
Display Format JA-{00000}
Starting Number 00001
Allow Reports Yes
Allow Activities Yes
Track Field History Yes
Deployment Status Deployed
Add Notes & Attachments related list to Yes
default page layout
Launch New Custom Tab Wizard after saving Yes
this custom object
93
Chapter 6: Expanding the Simple App Using Relationships
To create the Job Applications tab, select a Tab Style in the first step of the wizard, and
then accept all the defaults until you get to the Add to Custom Apps page. On this page, select
only the Recruiting app, and then click Save.
We're now just a few custom fields away from linking the Job Application object with the
Position and Candidate objects.
Although these fields are almost identical to the ones we created earlier, you'll notice when
you're defining the lookup relationship fields that there's a new step in the custom field wizard
Step 6: Add Custom Related Lists. This step of the wizard is where we can specify a heading for
the Job Applications related list that will show up on both the Candidate and Position detail
pages.
Why didn't we see this step earlier when we created our Hiring Manager lookup field? It
turns out that User is a unique standard object: it doesn't have a tab, and you cannot add related
lists to it. The platform knows this, so it leaves out the related list step whenever someone adds
a lookup relationship field that references the User object.
Now that we're all squared away with that small difference, let's finish up these Job Application
fields. Click Your Name ➤ Setup ➤ Create ➤ Objects, and then click Job Application to
view its detail page. In the Custom Fields & Relationships related list, use the New button to
create custom fields according to the following table. Where necessary, we've indicated some
additional values you'll need to fill in. Otherwise you can simply accept all defaults.
94
Expanding the Simple App Using Relationships
Before we move on, there is one more important step: we need to enter a name for the child
relationship that the Position field created between the Job Application and Position objects.
This step is only necessary for the Position relationship field because of how we will use this
relationship when we create our candidate map feature in Moving Beyond Point-and-Click
App Development on page 273.
1. Click Your Name ➤ Setup ➤ Create ➤ Objects, and click Job Application.
2. In the Custom Fields & Relationships related list, click Position, then click Edit.
3. In the Child Relationship Name field, enter Job Applications and click
Save. The Force.com platform saves the child relationship name as
Job_Applications.
95
Chapter 6: Expanding the Simple App Using Relationships
But there's more! Because we've built a couple of lookup relationships, our candidate and
position record detail pages now each have a new Job Applications related list. And the Job
Application detail page includes links to the candidate and position records that it references.
All three objects are now related and linked to one another!
96
Expanding the Simple App Using Relationships
Before we move on, let's see if we can clean up the usability of our app a bit more so our users
don't have to identify candidates and job applications by number when they click the lookup
button in the Job Application edit page, or when they look at the Job Applications related list
on the Candidate or Position detail pages.
97
Chapter 6: Expanding the Simple App Using Relationships
Likewise, the Job Applications related lists on the Position and Candidate detail pages only
display a job application number. It is much more useful if these related lists also include the
associated candidate's name or position.
To fix these issues, we can add fields to the search layouts for the objects that we've defined.
Search layouts are ordered groups of fields that are displayed when a record is presented in a
particular context, such as in search results, a lookup dialog, or a related list. By adding fields,
we can give users more information and help them locate records more quickly.
The Search Layouts related list on the custom object detail page is the place to modify these
sets of fields. Go to Your Name ➤ Setup ➤ Create ➤ Objects and select the Candidate
object. You'll see that the available search layouts include the following:
98
Expanding the Simple App Using Relationships
Note: The List View layout also appears in the Search Layouts related list, but it's
not for specifying fields. Instead, it allows you to specify the buttons that appear on
the list view page for an object.
The Edit Search Layout page includes a list of available fields from the Candidate object. You
can choose up to ten fields to include in the lookup dialog, and order them in any way you
choose, except that the object's unique name or number field (such as Candidate Number)
must be listed first.
4. Move the following fields into the Selected Fields box under Candidate Number:
• First Name
• Last Name
• City
• State/Province
• Phone
5. Click Save.
That's it! To try it out, return to the Job Applications tab, and click New. When you click the
lookup icon next to the Candidate field, the dialog is now much more useful.
99
Chapter 6: Expanding the Simple App Using Relationships
100
Expanding the Simple App Using Relationships
Now let's create another custom object to provide our hiring managers and interviewers with
a place to enter their comments about job applications.
The Review object has a many-to-one relationship with the Job Application object because
one job application can have one or more reviews associated with it. A related list on the job
application record will show the associated reviews, representing the “many” side of the
relationship.
101
Chapter 6: Expanding the Simple App Using Relationships
However, instead of creating this relationship with a lookup relationship field, this time we'll
use a master-detail relationship field. A master-detail relationship field makes sense in this
case because reviews lose their meaning when taken out of the context of a job application, so
we'll want to automatically delete reviews when we delete the job application to which they're
related.
Field Value
Label Review
Plural Label Reviews
Object Name Review
Description Represents an interviewer's assessment of a
particular candidate
Context-Sensitive Help Setting Open the standard Salesforce.com Help &
Training window
Record Name Review Number
Data Type Auto Number
Display Format R-{000000}
Starting Number 000001
Allow Reports Yes
102
Expanding the Simple App Using Relationships
Field Value
Allow Activities Yes
Track Field History Yes
Deployment Status Deployed
Add Notes & Attachments related list to Yes
default page layout
Launch New Custom Tab Wizard after saving No
this custom object
Notice that we didn't launch the tab wizard this time. Reviews don't need a tab of their own
because they can be accessed via a related list on the Job Application detail page. When you
create an object with a tab, the platform provides access to that object's records in various places
other than just the tab, such as in search results and the Recent Items list in the sidebar area
of every page. Because most Recruiting app users won't need to see reviews unless it's in the
context of a job application, we don't need to create a separate tab for them.
Notice that the Required checkbox is automatically selected and cannot be changed. As
mentioned earlier, master-detail relationship fields are always required on detail records.
103
Chapter 6: Expanding the Simple App Using Relationships
This sharing setting prevents people from creating, editing, or deleting a review unless they
can also create, edit, or delete the associated job application. We'll learn all about sharing and
security in the next chapter.
8. Click Next.
9. Accept the defaults in the remaining three steps of the wizard.
10. Click Save.
Your master-detail relationship is complete! Now that it's in place, let's think about the other
types of fields that would be useful to people looking at a review record.
Most likely, you are going to want to see the name of the candidate and the position for which
they are being reviewed. We could create a lookup relationship to the Position and Candidate
objects, and then require reviewers to enter those fields when creating a review record, but
what if they select the wrong value? Besides, wouldn't it be better if these fields were somehow
automatically populated?
To solve this, we'll tap into the synergy of formulas and relationships to create cross-object
formulas. Cross-object formulas are formulas that span two or more objects by referencing
merge fields from related records. This means that formulas on our Review object can access
fields on the Job Application object, and formulas on the Job Application object can access
fields on both the Position and Candidate objects. We're going to take it even one step further
by creating formula fields on our Review object that span the Job Application object to reference
fields on the Candidate and Position objects. You'll quickly discover that using related data is
much easier than it sounds!
Let's begin by building a formula field on the Review object that references the title of the
position on the review's parent job application record.
104
Expanding the Simple App Using Relationships
When you choose Review, the second column displays all of the Review object's fields as well
as its related objects, which are denoted by a greater-than sign (>). Notice that the Created
By and Last Modified By fields also have greater-than signs. This is because these are
lookup fields to the User object.
9. Select Job Application > in the second column. The third column displays the
fields of the Job Application object.
10. Select Position > in the third column. The fourth column displays the fields of
the Position object.
Be sure that you select Position > (with the greater than sign) and not Position. The
one with the greater-than sign is the Position object, while the one without the greater than
sign is the Position lookup field on the Job Application object. In most cases, formulas that
access lookup fields return a cryptic record ID. Instead, we want our formula to return the
position's title.
The formula spans to the review's related job application (Job_Application__r), then to
the job application's related position (Position__r), and finally references the position's title
(Name). Notice that each part of the formula is separated by a period, and that the relationship
names consist of the related object followed by __r.
105
Chapter 6: Expanding the Simple App Using Relationships
That wraps up our first cross-object formula field. Let's try another. This time, we'll add a
cross-object formula field on our Review object that displays the first and last names of the
candidate being reviewed. We'll also up the ante by using the HYPERLINK function so that
users can access the candidate's record by clicking the field.
The HYPERLINK function lets you create a hyperlink to any URL or record in Salesforce.com.
The text of the hyperlink can differ from the URL itself, which is useful here because we want
our hyperlink to display the first and last names of the candidate while the URL points to the
candidate record itself.
8. Delete url from the HYPERLINK function you just inserted, but leave your cursor
there.
9. Click the Insert Field button, and select Review >, Job Application >,
Candidate >, Record ID, and click Insert.
Salesforce.com generates a unique ID for every record. By inserting the record ID of the
candidate in our HYPERLINK function, we're enabling our formula field to locate and link to
the candidate's record.
10. Delete friendly_name from the HYPERLINK function, but leave your cursor there.
11. Click the Insert Field button, and select Review >, Job Application >,
Candidate >, First Name, then click Insert.
12. Enter a space, then click the Insert Operator button and choose Concatenate.
The Concatenate operator inserts an ampersand (&) in your formula, and joins the values on
either side of the ampersand. Here we're going to use the Concatenate operator to join the
first and last names of the candidate in a single field, even though they are stored in separate
fields on the Candidate object. The Concatenate operator also lets us insert a space between
the two names, as you'll see in the next step.
106
Expanding the Simple App Using Relationships
13. Enter another space, then type a blank space enclosed in quotes, like this:
" "
This appends a blank space after the first name of the candidate.
14. Enter a space, then click the Insert Operator button and choose Concatenate once
more to add a second ampersand in your formula.
15. Click the Insert Field button, and select Review >, Job Application >,
Candidate >, Last Name, then click Insert.
16. Delete [ target ] from the HYPERLINK function. This is an optional parameter
that isn't necessary for our formula field.
17. Click Check Syntax to check your formula for errors. Your finished formula should
look like this:
HYPERLINK
( Job_Application__r.Candidate__r.Id ,
Job_Application__r.Candidate__r.First_Name__c
&
" "
&
Job_Application__r.Candidate__r.Last_Name__c )
Whew! That one required a little more thought, but using a bit of brainpower here has
tremendously improved the usability of our app, which you'll see in a moment when we test
our changes to the Review object. Before we start testing, though, let's quickly add two more
easy fields to finish our Review object. We need a text area field for the reviewer's assessment,
and a number field in which the reviewer can give the candidate a numeric score.
Go to Your Name ➤ Setup ➤ Create ➤ Objects and select the Review object. Use the New
button in the Custom Fields & Relationships related list to create the remaining custom fields
for the Review object according to the following table. Where necessary, we've indicated some
additional values you'll need to fill in. Otherwise, accept all defaults.
107
Chapter 6: Expanding the Simple App Using Relationships
When you're done, add a quick validation rule to ensure that the Ratings field only accepts the
numbers 1 through 5. This will keep our review rating system consistent throughout our
organization.
This formula prevents the record from being saved if the value of the Rating field
is less than one or greater than five.
8. In the Error Message text box, enter Invalid rating. Rating must be
from 1 to 5.
9. Next to the Error Location field, select the Field radio button, and then choose
Rating from the drop-down list.
10. Click Save.
Our Review object is complete! We've added several features that will help users access the
data they need in order to asses each job application. There's just one more easy improvement
we need to streamline our job application review process. It involves returning to our Job
Application object and taking advantage of one of the benefits we gain by using a master-detail
relationship.
108
Expanding the Simple App Using Relationships
The good news is that we can! A simple roll-up summary field on the Job Application object
can summarize data from a set of related detail records and automatically display the output
on a master record. Use roll-up summary fields to display the sum, minimum, or maximum
value of a field in a related list, or the record count of all records listed in a related list.
Begin creating your roll-up summary just as you create any other custom field:
When creating a field on an object that is not the master in a master-detail relationship, the
Roll-Up Summary data type is not available. This is because roll-up summary fields are only
available on the master object in a master-detail relationship.
5. In the Field Label field, enter Total Rating. Once you move your cursor,
the Field Name text box should be automatically populated with Total_Rating.
6. Click Next.
7. In the Summarized Object drop-down list, choose Reviews.
8. Under Select Roll-Up Type, select SUM.
9. In the Field to Aggregate drop-down list, select Rating.
10. Leave All records should be included in the calculation selected,
and click Next.
11. Accept all remaining field-level security and page layout defaults.
12. Click Save.
Now our job application records aggregate the ratings of their related reviews. This data could
be a little deceptive, though, since some job applications might get reviewed more than others.
It would be more helpful if we could see the average rating.
109
Chapter 6: Expanding the Simple App Using Relationships
Roll-up summary fields themselves don't allow you to average values together, but you can use
them in formulas that do. Let's create a second roll-up summary field on the Job Application
object, and then build a simple formula field that uses both roll-up summary fields to find the
average rating.
We don't need to specify a Field to Aggregate this time since we're just counting the
number of related detail records and are not interested in any specific field.
Both roll-up summary fields are in place now. Let's build a formula field called Average
Rating that divides the value of the first roll-up summary field by the value of the second.
110
Expanding the Simple App Using Relationships
11. Choose Job Application >, then Number of Reviews, and click Insert. Your
formula should look like this:
Total_Rating__c / Number_of_Reviews__c
That wraps up all the fields and relationships we need to manage our reviews. Let's quickly
organize the presentation of our fields and then test everything we've created.
Try It Out: Customizing the Review Object's Page and Search Layouts
First, let's update the page layout of the Review object so that the Assessment text field is
in a single column section of the same name.
1. In the Search Layouts related list on the Review object detail page, click Edit next
to Lookup Dialogs and add the following fields:
• Review Number
• Rating
• Job Application
• Candidate
• Position
• Created Date
111
Chapter 6: Expanding the Simple App Using Relationships
To update the Reviews related list that appears on the Job Application detail page, we'll have
to edit the related list directly on the Job Application page layout. This is different from how
we added fields to the Job Application related list on the position and candidate detail pages
because the Review object doesn't have an associated tab, and therefore, doesn't have a tab
search layout. Remember—the tab search layout is responsible for both the fields that appear
in the list on the tab home page and the default fields that appear in related lists on other object
detail pages.
Note: The tab search layout is responsible for the fields in the related list layout only
if the related list properties have not been modified on other objects' page layouts. For
example, if you modify the properties of the Job Application related list on the Position
page layout, those changes will always override the field specifications of the Job
Application tab search layout.
Because the Review object doesn't have a tab search layout, we have to set those fields another
way.
• Review Number
• Rating
• Candidate
• Position
• Created Date
1. Click the Job Applications tab and select a record, or create one if you haven't already.
112
Expanding the Simple App Using Relationships
Tip: When you use the Candidate and Position lookup dialogs as you're creating a
job application record, note that, by default, they only display the most recently viewed
records. You can locate additional records by using the search box, which returns
records based on the Candidate Number or Position Title fields, respectively.
Use the * wildcard with other characters to improve your search results. For example,
searching on C* returns every candidate record. Likewise, searching on *e returns all
position records that include the letter 'e' in the title.
After the job application is created, notice that the Reviews related list now appears on the Job
Application detail page. That's because we related the Review object to the Job Application
object with a master-detail relationship.
Do you see how the platform automatically filled in the job application number in the review's
edit page? That's one of the small, but important, benefits of using the platform to build an
application like this—not only is it easy to create links and relationships between objects, but
the platform anticipates what we're doing and helps us accomplish our task with as few clicks
as possible.
Notice that the name of the candidate and the title of the position appear on the review detail
page. If you click the candidate's name, his or her record displays.
Go ahead and click around the rest of the app, creating a few more positions, job applications,
candidates, and reviews. Pretty neat, huh? Our data is all interconnected, and our edits to the
search layouts allow us to view details of several related objects all at once.
Here's where we get a little creative. Instead of creating a relationship field on the Position
object that directly links to the Employment Website object, we can link them using a junction
113
Chapter 6: Expanding the Simple App Using Relationships
object. A junction object is a custom object with two master-detail relationships, and is the key
to making a many-to-many relationship.
For our app, we're going to create a junction object called Job Posting. A job posting fits into
the space between positions and employment websites—one position can be posted many
times, and one employment website can have many job postings, but a job posting always
represents a posting about a single position on a single employment website. In essence, the
Job Posting object has a many-to-one relationship with both the Position and the Employment
Website objects, and through those many-to-one relationships, we'll have a many-to-many
relationship between the Position and Employment Website objects.
Tip: In many apps, the sole purpose of a junction object is to simply relate two objects,
so it often makes sense to give the junction object a name that indicates the association
or relationship it creates. For example, if you wanted to use a junction object to create
a many-to-many relationship between bugs and cases, you could name the junction
object BugCaseAssociation.
Let's look at a typical scenario at Universal Containers. There are open positions for a Project
Manager and a Sr. Developer. The Project Manager position is only posted on Monster.com,
but the Sr. Developer position is more difficult to fill, so it's posted on both Monster.com and
Dice. Every time a position is posted, a job posting record tracks the post. As you can see in
the following diagram, one position can be posted many times, and both positions can be
posted to the same employment website.
Figure 41: Using a Job Posting Object to Create a Many-to-Many Relationship Between
Positions and Employment Websites
In relational database terms, each job posting record is a row in the Job Posting table consisting
of a foreign key to a position record and a foreign key to an employment website record. The
following entity relationship diagram shows this relationship.
114
Expanding the Simple App Using Relationships
Figure 42: Entity Relationship Diagram for the Position, Job Posting, and Employment
Website Objects
To create our Employment Website custom object, navigate back to Your Name ➤ Setup ➤
Create ➤ Objects, click New Custom Object, and fill out the page according to the following
table.
Field Value
Label Employment Website
Plural Label Employment Websites
Object Name Employment_Website
Description Information about a particular employment
website
Context-Sensitive Help Setting Open the standard Salesforce.com Help &
Training window
Record Name Employment Website Name
Data Type Text
Allow Reports Yes
Allow Activities Yes
115
Chapter 6: Expanding the Simple App Using Relationships
Field Value
Track Field History Yes
Deployment Status Deployed
Add Notes & Attachments related list to Yes
default page layout
Launch New Custom Tab Wizard after saving Yes
this custom object
To create the Employment Website tab, select a Tab Style in the first step of the wizard,
and then accept all the defaults until you get to the Add to Custom Apps page. On this page,
select only the Recruiting App, and then click Save.
Let's wrap up the Employment Website object by adding a few custom fields.
Try It Out: Adding the URL Field to the Employment Website Object
Obviously, the Employment Website object needs to store the Web address of the employment
website. We'll use the URL data type for this field. That way, when users click the field, the
URL will open in a separate browser window. In addition to the URL, since most employment
websites charge per posting, we'll want to keep track of how much it costs to post there, as
well as our maximum budget for posting on the site.
Click Your Name ➤ Setup ➤ Create ➤ Objects, and then click Employment Website to
view its detail page. In the Custom Fields & Relationships related list, use the New button to
create custom fields according to the following table. Where necessary, we've indicated some
additional values you'll need to fill in. Otherwise you can simply accept all defaults.
Required
116
Expanding the Simple App Using Relationships
Required
Field Value
Label Job Posting
Plural Label Job Postings
Object Name Job_Posting
Description Represents the junction object between a
position and an employment website
Context-Sensitive Help Setting Open the standard Salesforce.com Help &
Training window
Record Name Job Posting Number
Data Type Auto Number
Display Format JP-{00000}
Starting Number 00001
Allow Reports Yes
Allow Activities Yes
Track Field History Yes
Deployment Status Deployed
117
Chapter 6: Expanding the Simple App Using Relationships
Field Value
Add Notes & Attachments related list to Yes
default page layout
Launch New Custom Tab Wizard after saving No
this custom object
That was simple enough, but we're not quite done. We need to create the master-detail
relationship fields that relate the Job Posting object with the Position and Employment Website
objects.
Here, we are given the chance to add the Job Postings related list to the Position object page
layout. Instead of displaying information about related job postings, we want this list to show
all the employment websites where this position is posted. So let's add the Job Posting related
list, but rename it Employment Websites.
118
Expanding the Simple App Using Relationships
We're halfway through the creation of our many-to-many relationship. The next step is to
create a second master-detail relationship on the Job Posting object to link it with the
Employment Website object.
The second master-detail relationship creates a secondary relationship. Unlike the primary
relationship, the secondary relationship has no affect on the look and feel of the junction object.
However, just as in the primary relationship, the sharing settings of the master record in the
secondary relationship also affect who can access the junction record, and deleting a record of
the secondary master object will automatically delete its associated junction object records. So
in our app, if you delete an employment website record, all of its associated job posting records
are deleted as well, even if the position is open.
This time we are given the chance to add the Job Postings related list to Employment Website
object page layout. We'll eventually configure this related list to show all the positions that are
posted on this website, so let's add the Job Postings related list but rename it Positions.
While we have an Employment Websites related list on the Position object and a Positions
related list on the Employment Websites object, both related lists still display job posting
records. This won't do.
In order to achieve our goal of listing multiple positions on an employment website record and
multiple employment websites on a position record, we need to customize the fields in these
related lists.
119
Chapter 6: Expanding the Simple App Using Relationships
Fortunately for us, many-to-many relationships allow for greater flexibility. When working
with a many-to-many relationship, the junction object's related list on one master object can
display the other master object's fields. We're going to take advantage of this by configuring
the Positions related list on each employment website record to display fields from the Position
object and vice versa, thus allowing these two objects to span to each other. It's all coming
together now!
Try It Out: Customizing the Positions and Employment Websites Related Lists
Let's start by modifying the Employment Websites related list on the Position object.
In the popup window that appears, you'll notice the Available Fields column lists fields
from both the Job Posting object and the Employment Website object. If there wasn't a
master-detail relationship between job postings and employment websites, the Available
Fields column list would only list job posting fields.
6. Click OK.
7. Click Save on the page layout.
120
Expanding the Simple App Using Relationships
Now do the same for the Positions related list on the Employment Website object as follows:
6. Click OK.
7. Click Save on the page layout.
The Employment Websites related list on that position now shows the name and Web address
of the website to which you just posted, as well as the job posting number. Click the name of
the employment website in the related list and scroll down to view the Positions related list,
which shows all the positions posted to that website.
Now you know how easy it is to make related information just a click away!
121
Chapter 6: Expanding the Simple App Using Relationships
All of these relationships, objects, and fields are shown below in an entity relationship diagram.
An entity relationship diagram (ERD) is a conceptual representation of structured data, and
is especially useful for planning and understanding an app.
122
Expanding the Simple App Using Relationships
We've now built all of our Recruiting app objects and tabs, and we've defined lots of custom
fields—everything from text fields and picklists to more complex formula fields and lookup
relationship fields. We've created a robust user interface so that our recruiters and hiring
managers can enter and retrieve data about positions and related candidates, job applications,
and reviews, and we did all of this without writing a single line of code!
Remember when we assigned Clark Kentman as the hiring manager for the Benefits Specialist
position? Let's look at what Clark can do now: He can create and update his positions, and
track which websites he's posted them on. He can look at details about any candidates who
have applied for the Benefits Specialist job, and he can review their related job applications.
123
Chapter 6: Expanding the Simple App Using Relationships
He can also check the status of the job applications. He no longer has to go to Human Resources
to search through Microsoft Word documents and spreadsheets to manage his tasks in the
hiring process. The Recruiting app is well on its way to becoming a fully-functional and useful
application!
However, before we leave this chapter behind, let's get ourselves prepared for the rest of this
book by creating and importing some real data. It'll help us when we get to our next chapter
on security and sharing if we have some records that we can work with.
Before we import anything, we need to make a modification to the import file for positions.
The sample Positions.csv you downloaded contains fictional users in the Hiring Manager
column. The names of these users most likely won't match any user in your organization, and
if you import the file “as is,” the Import Wizard won't be able to find any matching users, and
the Hiring Manager field on each position record will be left blank. So let's go ahead and
make that change.
Note: If your locale isn't English (United States), the date and field values in
Positions.csv are also invalid. You'll need to change them before you import.
124
Expanding the Simple App Using Relationships
Use the following table to repeat the import process for candidate records. You'll notice the
wizard skips the two steps about lookup relationship field matching—because the Candidate
object doesn't have any lookup relationship fields, the Import Wizard automatically leaves
those steps out.
Finally let's do it one more time for job application records. In this iteration, we're going to
make use of the Email field, an external ID on the Candidate object, to match up job
applications with the correct candidate records.
Great! While the files are importing, you can go to Your Name ➤ Setup ➤ Monitoring ➤
Imports to check on their status.
Once the import operations have completed, return to the Positions, Candidates, or Job
Applications tab and click Go! next to the View drop-down list. You'll see a list of all the new
records you just imported.
We've just added a bunch of data to our app without a lot of work. In the next chapter, we'll
take a look at all the ways we can control access to this data using the built-in tools of the
platform. We'll get into the nitty-gritty about security, sharing rules, permissions, roles, and
profiles.
126
Chapter 7
Securing and Sharing Data
In this chapter ... Now that we've got all of our object relationships in place,
it's time to start thinking about who's actually going to be
• Controlling Access to using the app and how much access they should have to all
Data in Our App of the data that it's going to contain.
• Data Access Concepts
• Controlling Access to As with many apps, our Recruiting app exposes sensitive
pieces of data such as social security numbers, salary
Objects
amounts, and applicant reviews that could really come back
• Controlling Access to to haunt us if they fell into the hands of the wrong people.
Fields We need to provide security without making it harder for
• Controlling Access to our recruiters, hiring managers, and interviewers to do their
Records jobs.
• Displaying Field Values
and Page Layouts Here we're going to see another one of the huge benefits
According to Profiles that the Force.com platform has to offer. You get
simple-to-configure security controls that easily allow us to
• Putting It All Together
restrict access to data that users shouldn't see, without a lot
• Delegating Data of headaches. Similar to Access Control Lists or Windows
Administration folder permissions, the Force.com platform allows us to
• Summing Up specify who can view, create, edit, or delete any record or
field in the app. In this chapter, we'll see how we can use
the Force.com platform to implement those rules.
127
Chapter 7: Securing and Sharing Data
One by one, let's take a look at the kinds of access that each one of these users needs and, more
importantly, the kinds of access they don't need to do their jobs. Once we've compiled a set of
required permissions, we'll figure out how to implement them in the rest of the chapter.
Although Mario has the most powerful role in our Recruiting app, we still can't give him
complete free reign. While it's OK for job posting and employment website data to be
permanently deleted at any time, state and federal public records laws require that all other
recruitment-related records be saved for a number of years so that if a hiring decision is
questioned, it can be defended in court. Consequently, we need to make sure that Mario will
never accidentally delete a record that needs to be saved to fulfill the law.
But how will he keep the number of positions, candidates, job applications, and reviews in
check if he can't delete them? Won't the app become swamped with old data? Not if we're
smart about it—instead of having Mario delete old records, we can use the Status field on
a record as an indication of whether it's current. We'll filter out all of the old records by using
a simple list view.
Here's a summary of the required permissions that we need to implement for a recruiter:
128
Securing and Sharing Data
129
Chapter 7: Securing and Sharing Data
manager. Also, since Ben has no reason to see a candidate's social security
number, this field should be restricted from his view.
Job Application
As the hiring manager, Ben needs to be able to update the status of those
job applications to specify which candidates should be selected or rejected.
However, he should not be able to change the candidate listed on the job
application, nor the position to which the candidate is applying, so we'll
have to find a way of preventing Ben from updating the lookup fields on
job applications.
Review
To make a decision about the candidates who are applying, Ben needs to
see the reviews posted by the interviewers, as well as make comments on
them if he thinks the interviewer was being too biased in his or her review.
Likewise, Ben needs to be able to create reviews so that he can remember
his own impressions of the candidates he interviews.
Job Posting
Ben wants to make sure his harder-to-fill positions are visible to the most
talented people in the field. The most efficient way to do this is by posting
open positions on various employment websites. Given that employment
websites have different types of users with varying skill sets, we should
give Ben the power to unilaterally create job postings on employment
websites, since Ben is the best person to ascertain which skill sets are
necessary for his open positions.
Employment Website
If Ben had his way, he would usurp all of the company's budget for posting
his open positions on employment websites; therefore, Ben shouldn't be
allowed to modify employment website records, as that would let him
redefine the company's budget for posting jobs and could lead to an
accounting fiasco. Still, we need to make sure that Ben can view
employment website records to get an idea of the employment websites
with which Universal Containers has accounts, and how much of the
budget for that employment website is available.
Here's a summary of the required permissions we need to implement for a hiring manager:
130
Securing and Sharing Data
* Only for those records that are associated with a position to which the hiring manager has
been assigned
Melissa must be able to create and edit her reviews so that she can record her comments about
each candidate, but she shouldn't be able to see the reviews of other interviewers—reading
them might sway her opinion one way or the other. As with hiring managers and recruiters,
Melissa also shouldn't be allowed to delete any records to ensure that public records laws are
fulfilled.
Finally, the posting of jobs to employment websites has no bearing on Melissa's responsibilities,
so both the employment website and job posting records should be completely off-limits to
her.
131
Chapter 7: Securing and Sharing Data
* Only for those records that are associated with a position to which the interviewer has been
assigned
Here's a summary of the required permissions we need to implement for a standard employee:
132
Securing and Sharing Data
Standard • Read - - - - -
Employee (No
min/max
pay)
* Only for those records that are associated with a position to which the hiring
manager/interviewer has been assigned
Tip: When implementing the security and sharing rules for your own organization,
it's often useful to create a required permissions table like this to organize your thoughts
and make sure you don't forget to restrict or grant access to a particular user. You'll
133
Chapter 7: Securing and Sharing Data
see that we're going to refer back to this table again and again as we go through this
chapter.
The combination of all of these sharing and security settings in the platform means that we
can easily specify user permissions for an organization of thousands of users without having to
manually configure the permissions for each individual. Pretty neat! Now let's get started
learning more about each of these methods for controlling data, and actually implementing
the security and sharing rules for our app.
135
Chapter 7: Securing and Sharing Data
Introducing Profiles
A profile is a collection of settings and permissions that determine what a user can do in the
platform, kind of like a group in a Windows network, where all of the members of the group
have the same folder permissions and access to the same software. Profiles control:
• The objects the user can view, create, edit, and delete
• The object fields the user can view and edit (more on that later!)
• The tabs the user can view in the app
• The standard and custom apps the user can access
• The page layouts a user sees
• The record types available to the user
• The hours during which the user can log in to the app
• The IP addresses from which the user can log in to the app
Profiles are typically defined by a user's job function (for example, system administrator or
sales representative), but you can have profiles for anything that makes sense for your
organization. A profile can be assigned to many users, but a user can be assigned to only one
profile at a time.
Standard Profiles
The platform provides the following set of standard profiles in every organization:
• Read Only
• Standard User
• Marketing User
• Contract Manager
• Solution Manager
• System Administrator
136
Securing and Sharing Data
Each of these standard profiles includes a default set of permissions for all of the standard
objects available on the platform. For example, users assigned to the Standard User profile can
never create, edit, or delete a campaign.
When a custom object is created, most profiles (except those with “Modify All Data”) don't
get access to the object. You can find more detailed descriptions of all the standard profiles in
the online help, but the important thing to know is that you can never actually edit the
permissions on a standard profile. Instead, if you have access to the Enterprise, Unlimited, or
Developer Editions of the platform, you can make a copy of a standard profile and then
customize that copy to better fit the needs of your organization. That's what we're going to
end up doing for our Recruiting app (and as a result, Enterprise, Unlimited, and Developer
Editions will be the only editions that the Recruiting app will support).
Recruiters are pretty straightforward—they definitely represent a particular job function, and
they need access to different types of data than other users. They need their own profile.
A hiring manager, however, is not exactly a single type of position. For most organizations, a
hiring manager in the Sales department will almost certainly need access to a different type of
data than a hiring manager in Engineering. However, for the purposes of our app, sales managers
and software managers still need the same types of access to recruiting data—reviews, candidates,
positions, job applications, job postings, and employment websites. Let's keep this as a single
profile for now, but if incorporating our app into an organization with other CRM functionality,
we'll need to suggest as a best practice that the hiring manager permissions for recruiting-related
data need to be replicated for any profile to which hiring managers belong.
Finally, let's look at interviewers and standard employees. Neither one of these user types
reflects a particular job function, and when you think about it, just about anyone in an
organization might be called upon to perform an interview. Let's define a single profile for a
standard employee and find a way to grant interviewers access to the records that they need
through some other mechanism. (Hint: we can use a combination of organization-wide defaults
and sharing rules to make this work.)
137
Chapter 7: Securing and Sharing Data
Here you should see the list of standard profiles that we talked about earlier. After we create
our custom profiles, they'll also show up in this list.
First, we can quickly tell which profiles we can play with by looking at the Custom column—if
it's checked, that means it's a custom profile and we can edit anything about it. If that column
is not checked, we can still click the Edit link; we just can't modify any of the permission
settings. (What does that leave for us to edit on a standard profile? Well, we can choose which
tabs should appear at the top of a user's page, and we can also select the apps that are available
in the Force.com app menu in the top-right corner of the page.)
2. Create a new profile named Recruiter based on the Standard User profile.
There are actually two ways of doing this—we can either click New, select an existing profile
to clone, name it, and click Save, or we can simply click Clone in the detail page of the profile
that we want to copy, name it, and click Save. Ultimately, it's the same number of clicks, so
choose the method you like best. Standard User is the profile that most closely resembles what
we want our new Recruiter profile to look like, so it's a good starting point.
The Recruiter edit page should look and function exactly like the Standard User profile edit
page except with one important difference: you have the ability to modify any of the permission
settings.
138
Securing and Sharing Data
4. In the Custom App Settings area, make the Recruiting app visible to users assigned
to the Recruiter profile, as shown in the following screenshot.
Tip: You can also give this profile access to any of the other available apps as well.
Every profile needs to have at least one visible app.
When an app is visible, a user can select it from the Force.com app menu at the top-right
corner of the page. Be aware, however, that even if an app is visible, the app's tabs won't show
up unless a profile has permissions to view the tabs and permission to view the associated
object. (We'll set both of those permissions lower down in the Profile edit page.)
Making this selection means that the Recruiting app will be displayed when a user logs in.
You'll notice that when you select an app as the default, its Visible checkbox is automatically
selected, because it doesn't make sense for an app to be the default if it's not visible to the user.
6. In the Tab Settings area, select Default On for the Positions, Job Applications,
Candidates, and Employment Websites tabs.
Tip: You can choose whether you want other tabs to be displayed based on the
additional apps that you made visible in the last step.
For the purposes of our Recruiting app, all of our custom recruiting tabs are on by default. For
any other tabs that you select, you can choose which should be displayed on top of the user's
page (Default On), hidden from the user's page but available when he or she clicks the All
Tabs tab on the far right (Default Off ), or completely hidden from the user (Tab Hidden).
Realize that even if you completely hide a tab, users can still see the records that would have
appeared in that tab in search results and in related lists. (To prevent a user from accessing
data, we have to set the proper restrictions in the Standard and Custom Object Permissions
areas lower down in the Profile edit page—we'll get there shortly!)
The Overwrite users' personal tab customizations setting appears if you have
an organization that's currently in use and you want to make sure your existing users are viewing
the tabs that you've selected. You don't need to select this for our app because we're defining
139
Chapter 7: Securing and Sharing Data
a brand-new profile and no one has personalized his or her tab visibility settings yet. However,
if you do want to select this option at some point in the future, just make sure you're not going
to annoy your users by deleting all of their customizations!
Just below the Tab Settings area, the Administrative and General User Permissions areas of
the profile allow you to grant special access to features and functionality that don't map directly
to particular objects. None of these permissions affects our Recruiting app, but you can learn
more about them in the online help.
7. In the Custom Object Permissions area, specify the object-level permissions for our
Recruiter profile according to the following table.
140
Securing and Sharing Data
Tip: Depending on the apps that you made visible previously, you can also set
additional object permissions on standard or other custom objects.
Since there are no instances when a recruiter should be allowed to delete positions, candidates,
job applications, and reviews, we should make sure that the object-level permissions for deletion
are turned off for these objects. Also, make sure the “View All” and “Modify All” permissions
are only selected for job postings and employment websites. These are special kinds of object
permissions that we'll discuss later in this chapter.
By restricting the power to delete recruiting-related objects here, recruiters will never be able
to delete these objects. However, the fact that we're granting recruiters permission to create,
read, or edit our recruiting objects does not necessarily mean that recruiters will be allowed to
read or edit every recruiting object record. Why?
Here we see the result of two really important concepts in the platform:
What this means is that even though we are granting this profile create, read, and edit
permissions on the recruiting objects, if the record-level permissions for an individual recruiting
record prove to be more restrictive, those will be the rules that will define what a recruiter can
access.
For example, our new profile gives a recruiter permission to create, edit, and view reviews.
However, if we set organization-wide defaults for reviews to Private (a record-level permission),
our recruiter will be allowed to edit and view only his own reviews, and not the reviews owned
by other users. We'll learn more about record-level permissions later and go through more
examples of how they work with the object-level ones, but for now, just understand that
object-level permissions are only one piece of the puzzle.
8. Click Save to create your profile and return to the profile detail page.
141
Chapter 7: Securing and Sharing Data
Congratulations! We're done with our first profile. As you can see, it really wasn't that hard,
because we'd already analyzed our required permissions and knew what objects recruiters will
need access to. In the next section, let's quickly finish up our other two profiles and then move
on to field-level security.
To make each profile, go ahead and follow the steps that we outlined in the previous section.
The important things to remember for these profiles are:
• The profiles should be named Hiring Manager and Standard Employee and should be
based on the standard profile that best fits your needs. We used Standard User for our
Recruiter profile, and that's probably a good one for Standard Employee as well. However,
for your organization you might find that Hiring Manager more closely resembles the
Contract or Solution Manager profile instead. It's up to you.
• The Recruiting app for both profiles must be set to Visible.
• For the Hiring Manager profile, set the tabs for Positions, Candidates, Job Applications,
and Employment Websites to Default On.
• For the Standard Employee profile, set the tabs for Positions, Candidates, and Job
Applications to Default On, but set the tab for Employment Website to Tab Hidden.
• Standard and custom object permissions should reflect the required permissions that we
worked on before.
To refresh our memories, let's take a look at our required permissions summary table:
Table 27: Summary of Required Permissions: Hiring Manager, Interviewer, and Standard
Employee
142
Securing and Sharing Data
Standard • Read - - - - -
Employee (No
min/max
pay)
* Only for those records that are associated with a position to which the hiring
manager/interviewer has been assigned
This table is a little confusing right now, because Interviewer and Standard Employee are still
separated into two different users. Let's go ahead and combine them into a single Standard
Employee user so that it's a little easier to see what object-level permissions we need to grant.
It's easy to do, because Interviewers and Standard Employees have the same permissions on
the Position object, and we already have asterisks on Candidates, Job Applications, and Reviews
that ensures these users won't look at anything to which they're not assigned as an interviewer:
143
Chapter 7: Securing and Sharing Data
* Only for those records that are associated with a position to which the hiring manager/standard
employee has been assigned
Great, but what about all of those asterisks and restrictions on visible fields? Do we need to
take those into account when we set our object-level permissions?
Not at all. Those asterisks and field restrictions represent record- and field-level security settings
that we're going to have to specify elsewhere in our app. The only things we need to care about
here are the permissions that these users will need to have access to at least some of the
time—that's the whole point of object-level permissions:
• For hiring managers, that's create, read, and edit on Positions and Reviews, read on
Candidates and Employment Websites, and read and edit on Job Applications
• For standard employees, that's read on Positions, Candidates, and Job Applications, and
create, read, and edit on Reviews
Fantastic! We've just finished defining profiles and object-level permissions for all the users
in our Recruiting app. However, that's still just one piece of the security and sharing puzzle—we
still need to make sure that sensitive data on these objects is protected from users who don't
144
Securing and Sharing Data
need access, and then we need to drill down on the actual records that each user should be
allowed to view and edit.
Unlike page layouts, which only control the visibility of fields on detail and edit pages, field-level
security controls the visibility of fields in any part of the app, including related lists, list views,
reports, and search results. Indeed, in order to be absolutely sure that a user can't access a
particular field, it's important to use the field-level security page for a given object to restrict
access to the field. There are simply no other shortcuts that will provide the same level of
protection for a particular field.
145
Chapter 7: Securing and Sharing Data
* Only for those records that are associated with a position to which the hiring manager/standard
employee has been assigned
For field-level security settings, we'll first zero in on those rules that include field restrictions
in parentheses, specifically:
• On the Position object, hide minimum and maximum pay from standard employees
• On the Candidate object, hide social security numbers from hiring managers and standard
employees
• On the Job Application object, make the Position and Candidate lookup fields read-only
for hiring managers.
The path that you choose depends on whether you're focused solely on field-level security, or
whether you want to fiddle with page layout settings at the same time. The first way is the
simplest and requires the least number of clicks, but the second is sometimes more convenient
when you're building a new app, because you can perform two related tasks in the same page.
146
Securing and Sharing Data
Because we have two different field rules that we need to implement for our Recruiting app,
we'll define one rule with the first method, and the other with the second.
1. Click Your Name ➤ Setup ➤ Manage Users ➤ Profiles, and then select the
Standard Employee profile.
The first thing you'll notice about the Standard Employee profile's detail page is that it includes
several more areas than the edit page that we originally used to define the profile. These
additional areas include Page Layouts (which we learned about in Enhancing the Simple App
with Advanced Fields, Data Validation, and Page Layouts on page 52), Field-Level Security,
Record Type Settings, Login Hours, and Login IP Ranges. Although we won't go into detail
in this book about how to use any areas other than Field-Level Security (and record types later
on), they're part of what makes a profile so powerful in our application. You can learn more
about them in the online help.
2. In the Field-Level Security area, click View next to the Position object.
147
Chapter 7: Securing and Sharing Data
3. Click Edit.
Here we see security settings for all of the fields on the Position object, including Min Pay
and Max Pay, the two fields that we want to restrict. You'll notice that some field-level security
settings on some fields cannot be modified—this is because either they are system-generated
fields or they act as lookup relationship fields (foreign keys) to other records.
Since the security settings checkboxes can be a little bit confusing, let's do a quick exercise to
map their values (Visible and Read-Only) to the three logical permission settings for a
field: “Hidden,” “Read Only,” and “Editable”:
148
Securing and Sharing Data
After doing this exercise, it's easy to see that most fields are editable, because their Visible
checkbox is the only one selected. To restrict a field from ever being viewed by a user, all we
have to do is deselect both checkboxes.
We're done!
1. Click Your Name ➤ Setup ➤ Security Controls ➤ Field Accessibility, and then
select the Candidate object.
Notice that with the Field Accessibility tool, we start off by choosing the relevant object, rather
than a user profile. Then, we can choose to set field-accessibility either by selecting a single
field and then seeing its security settings for every profile (View by Fields), or by selecting a
profile and then seeing security settings for every field (View by Profile).
2. Click View by Fields, and then select SSN from the Field drop-down list.
149
Chapter 7: Securing and Sharing Data
The table that appears shows us the accessibility settings for social security number for each
profile. If you move your mouse over the value for Field Access, hover text indicates whether
the security setting is the result of a page layout setting or a field-level security setting.
150
Securing and Sharing Data
By clicking the value in a profile's Field Access column, we finally get to see the real reason
why the Field Accessibility page is so convenient: we can view and edit a field's field-level
security and page layout settings in the same page.
The Field-Level Security area includes the same checkboxes that we discussed previously—to
hide the social security number from hiring managers, we can simply deselect the Visible
checkbox as we did with the Min Pay and Max Pay fields on positions.
Before we do that, however, take a look at the Page Layout area. Here you can either change
the visibility and editability of the field on the page layout, or you can choose a different page
layout for the Hiring Manager profile altogether. Since we are focused on the security of the
SSN field in this exercise we don't need to touch any of the Page Layout area settings. However,
you should remember that this tool is here for the future, especially if you are ever trying to
figure out why a field is or is not visible to a particular user.
To finish up, all we need to do is repeat the process for the Standard Employee profile.
151
Chapter 7: Securing and Sharing Data
We have just one more field-level security setting to make! In this next one, we'll leave the
field values visible, but prevent them from being edited by hiring managers.
1. Click Your Name ➤ Setup ➤ Manage Users ➤ Profiles, and then select the Hiring
Manager profile.
2. In the Field-Level Security area, click View next to the Job Application object.
3. Click Edit.
4. Next to the Candidate field, select Read-Only.
5. Next to the Position field, select Read-Only.
6. Click Save.
All done! We've just finished the second piece of our security and sharing puzzle by defining
field-level security for the sensitive fields in our Recruiting app. Now, for the final (and most
complicated) piece of the puzzle, we need to specify the individual records to which each user
needs access. We need to protect our data without compromising any employee's ability to
perform his or her job.
152
Securing and Sharing Data
data to this most restrictive level, and then we'll use our other record-level security and sharing
tools (role hierarchies, sharing rules, and manual sharing) to open up the data to other users
who need to access it.
Based on our answers to these questions, we can determine the sharing model that we need
for that object as illustrated in the following diagram.
153
Chapter 7: Securing and Sharing Data
For example, let's consider the Position object in our recruiting app. To refresh our memories,
here's our table of required permissions:
154
Securing and Sharing Data
* Only for those records that are associated with a position to which the hiring manager/standard
employee has been assigned
Now let's go through and answer our list of questions for the Position object:
Table 32: Determining Org-Wide Defaults for the Standard Employee Profile
Question Answer
1. Who is the most restricted user of this object? A member of the Standard Employee profile.
All that they're allowed to do is view a
position.
2. Is there ever going to be an instance of this No. Although the values for the minimum
object that this user shouldn't be allowed to see? and maximum pay are hidden from standard
employees, they're still allowed to view all
position records.
155
Chapter 7: Securing and Sharing Data
Question Answer
3. Is there ever going to be an instance of this Yes. Standard employees aren't allowed to edit
object that this user shouldn't be allowed to edit? any position record.
According to our flowchart, answering “Yes” to question #3 means that the sharing model for
the Position object should be set to Public Read-Only.
The same is true for the Employment Website and Job Posting objects, except hiring managers
are the most restricted users instead of standard employees. We want to allow hiring managers
to view all employment website and job posting records without being able to edit them, so
the answer to the second question is “No” while the answer to the third question is “Yes;”
therefore, the sharing model for the Employment Website and Job Posting objects should be
Public Read-Only.
Going through the rest of our recruiting objects required permissions, we can easily figure out
their sharing models, too. The Standard Employee profile is the most restricted user for each
object, and there are going to be candidate, job application, and review records that particular
employees won't be able to view. Consequently, the sharing model for the Candidate, Job
Application, and Review objects should all be set to Private.
1. Click Your Name ➤ Setup ➤ Security Controls ➤ Sharing Settings. If you see
an introductory splash page, click Set Up Sharing at the bottom of the page to skip
to the actual tool.
The Sharing Settings page is where we control both org-wide defaults and sharing rules. We'll
talk more about this page when we talk about sharing rules a little further down. For now, let's
just edit our org-wide default settings.
156
Securing and Sharing Data
This page controls the org-wide defaults for every object in our organization. You'll notice that
some standard objects (like leads and calendars) use a different set of org-wide default values
than we have available for our custom recruiting objects. You can learn more about them in
the online help. For now, let's just set our recruiting objects to the org-wide defaults that we
decided on in the last section.
Right about now, you're probably wondering why you can't set the org-wide defaults for the
Review and Job Posting objects. The reason is that those objects are on the detail side of
master-detail relationships, and, as mentioned in the last chapter, a detail record automatically
inherits the sharing setting of its parent. So in our app, the Review object is automatically set
to Private, and the Job Posting object is automatically set to Public Read Only.
You also might be wondering about the Grant Access Using Hierarchies column of
checkboxes. Leave these selected for now. We'll discuss hierarchies in the next section.
5. Click Save.
Easy! Now that we've locked down our data with org-wide defaults, users are currently allowed
to work on only candidate, job application, and review records that they own, and are allowed
157
Chapter 7: Securing and Sharing Data
to view position, employment website, and job posting records that anyone owns. Because
those settings are way too restrictive for any user to get any benefit out of our app, now we
need to use role hierarchies, sharing rules, and manual sharing to open up candidate, job
application, and review record access to those employees who'll need it.
To illustrate, let's take a look at a portion of the role hierarchy for Universal Containers:
Role hierarchies don't necessarily need to match your org chart exactly. Instead, each role in
the hierarchy should just represent a level of data access that a user or group of users needs.
For example, suppose your organization employs a corporate lawyer who needs to access all of
the records in the app. One easy way to accomplish this is by assigning the lawyer to the CEO
role in your organization's role hierarchy. Since the CEO role is placed at the top of the
hierarchy, anyone assigned to that role automatically gets full access to any record in the
158
Securing and Sharing Data
organization. It doesn't matter that technically the lawyer appears below the CEO in the regular
org chart.
Also, role hierarchies don't necessarily need to apply to all of your custom objects. You can use
the Grant Access Using Hierarchies checkbox to enable and disable record access
through hierarchies on an object-by-object basis when you set your org-wide defaults. For our
Recruiting app, however, we want our role hierarchy to apply to all of our custom objects, so
leave all of the Grant Access Using Hierarchies checkboxes selected.
As we learned earlier in this chapter, profiles control a user's object- and field-level access
permissions. Indeed, a user can't be defined without being assigned to a particular profile, since
the profiles specifies the apps and tabs that appear when he or she logs in, among a number
of other useful things.
Roles, on the other hand, primarily control a user's record-level access permissions through
role hierarchy and sharing rules. Although a role assignment isn't exactly required when we
define a user, it would be foolish of us not to assign a role since it makes it so much easier to
define our record-level permissions. Indeed, trying to define record-level permissions without
assigning a role to a user would be a lot like trying to travel from New York to San Francisco
by car when there's an airplane available—there's just a much more efficient way of doing it!
Because profiles control object- and field-level access whereas roles influence record-level
access, a user is typically assigned to one of each. To help you remember which controls what,
remember: Roles control Records.
• The CEO, Cynthia Capobianco, will be able to view and update every record that anyone
else in the organization can view and update.
159
Chapter 7: Securing and Sharing Data
• The VP of Development, Andrew Goldberg, will be able to view and update any record
that his managers or his managers' employees can view or update.
• The VP of Human Resources, Megan Smith, will be able to view and update any record
that Phil Katz, her recruiting manager, or Mario Ruiz, Phil's recruiter, can view and update.
• The Recruiting Manager, Phil Katz, will be able to view and update any record that is
owned by Mario Ruiz, his recruiter.
• The Software Development manager, Ben Stuart, will be able to view and update any record
that is owned by Melissa Lee, Tom Zales, or Craig Kingman, his software engineers.
• The director of QA, Clark Kentman, will be able to view and update any record that is
owned by Flash Stevenson or Harry Potterham, his QA Engineers.
• The director of Product Management, Frank Linstrom, will be able to view and update
any record that is owned by Amy Lojack or Andy Macrola, his product managers.
As we can see, the role hierarchy is very powerful in opening up data for people high up in the
role hierarchy tree! However, let's look at some of the gaps that we still have in our record-level
permissions:
• Megan Smith (and her whole recruiting team) won't be able to view any reviews that are
owned by members of Andrew Goldberg's Development team because she doesn't have a
direct line down to any Development roles in the role hierarchy.
• Ben Stuart, the software development manager, also won't be able to see any reviews that
were written by members of the QA or Product Management groups, even if QA engineers
or product managers interviewed candidates for a software engineering position in his
group.
• Melissa Lee, a software engineer, won't be able to see the records for candidates that she's
supposed to interview.
Clearly we'll need to use other record-level sharing methods to open up data between peers in
the same group, and also between groups that appear in different branches of the role hierarchy
(we'll get to those later in this chapter). However, the role hierarchy does give us a good start
toward opening up record access, so let's take a look now at how to define it.
160
Securing and Sharing Data
Once that's all squared away, we can get started actually defining the role hierarchy itself. For
our exercise, we'll go ahead and use the role hierarchy that we talked about in the previous
sections.
1. Click Your Name ➤ Setup ➤ Manage Users ➤ Roles. If you see an introductory
splash page called Understanding Roles, click Set Up Roles at the bottom of the
page to skip to the actual tool.
The default view for this page is the tree view, as indicated in the drop-down list on the far
right side of the Role Hierarchy title bar. When creating a role hierarchy, it's probably easiest
to stick with this or the list view, because they both make it easy to see how the roles all fit
together in the hierarchy. The sorted list view is best if you know the name of a role that you
want to find but aren't sure where it fits in the hierarchy, or if you don't want to click open all
the tree nodes. For our purposes, we'll stick with the tree view for now.
When you first start defining a role hierarchy, the tree view displays a single placeholder node
with the name of your organization. From this point, we need to add the name of the role that
is highest up in the hierarchy—in our case, the CEO.
Note: If you're building your Recruiting app with a free Developer Edition
organization, you may have a role hierarchy predefined as a sample. That's alright.
You can still follow along and create some more roles.
By choosing the name of the organization in the This role reports to text box, we're
indicating that the CEO role is a top-level position in our role hierarchy and doesn't report to
anyone.
161
Chapter 7: Securing and Sharing Data
5. In the Role Name as displayed on reports text box, enter CEO. This text
is used in reports to indicate the name of a role. Since you may not want a long role
name, like Vice President of Product Development, taking up too much space in
your report columns, it's advisable to use a shortened, yet easily identifiable,
abbreviation.
6. Leave any other options, such as Opportunity Access, set to their defaults. These
access options don't have anything to do with our Recruiting app, and only appear
if you have the org-wide defaults for a standard object set to a level more restrictive
than Public Read/Write.
7. Click Save.
Now that we've created our first role, we can assign the appropriate user to it.
If we return to the main Roles page by clicking Your Name ➤ Setup ➤ Manage Users ➤
Roles, we can now see our new CEO role in the hierarchy. Defining the rest of the roles is
just an exercise that you can do on your own according to the Universal Containers Role
Hierarchy diagram (If you don't define the role hierarchy, some of the tests that we talk about
later won't work as described.)
162
Securing and Sharing Data
Note: There's no need to assign users to every role at this point—we'll do that later
when we test out our app.
Tip: To speed up the process of adding a new role, click Add Role directly under the
name of the role to which the new role should report. When you do this, the This
role reports to text box is automatically filled in with the name of the appropriate
role.
Not too hard, right? With org-wide defaults and a role hierarchy in place, we're actually pretty
close to finishing up our record-level access permissions. All we have left to do is share
recruiting-related records between groups that appear in separate branches of the role hierarchy,
and between peers in a single group. Fortunately, we can accomplish both of those tasks with
a combination of sharing rules and manual sharing. We just need to figure out what's left that
needs to be shared, and with whom.
• Recruiters need read and update access on every position, candidate, job application, and
review record that exists in the app.
• Hiring managers need:
- Read and update access on position and job posting records on which they're the hiring
manager
- Read access on candidate records for which they're the hiring manager
- Read and update access on every job application and review record
• Interviewers need read access on the candidate and job application records for people they're
interviewing, and the ability to update their reviews.
163
Chapter 7: Securing and Sharing Data
with the roles that we created in the previous section, but we can also make up other groups
as needed.
The thing to remember with sharing rules is that, like role hierarchies, we can use them only
to open up record access to more users. Sharing rules and role hierarchies can never be stricter
than our org-wide default settings.
Alternatively, consider another use case from our Recruiting app: interviewers need read access
on the candidates and job applications for people they're interviewing. In this case, the set of
interviewers is a lot harder to predict in advance—hiring managers might use different sets of
interviewers depending on the position for which they're hiring, and the interviewers might
come from different groups in the role hierarchy. As a result, this use case probably shouldn't
be handled with sharing rules—the team of interviewers for any given manager is just too hard
to predict.
Let's go through the set of required permissions we still need to implement and pick out the
ones that would work best with sharing rules:
164
Securing and Sharing Data
Great! Now that we know the required permissions we want to implement with sharing rules,
let's go ahead and define them.
Looking at the required permissions that we want to implement, there are just two objects that
need a public group for their sharing rules: Job Application and Review. The good news is that
we can cover these objects in a single group because the Review object is on the detail side of
a master-detail relationship, so it inherits the sharing settings we apply to the Job Application
object. Since both recruiters and hiring managers need read and update access to job applications
and reviews, let's go ahead and make a public group called Reviewers that encompasses recruiters
and hiring managers.
165
Chapter 7: Securing and Sharing Data
The New Public Group page allows you to choose other public groups, individual roles,
individual roles including the roles' subordinates, or individual users.
Try It Out: Defining a Sharing Rule for Job Application and Review Records
Since we just defined our Reviewers public group, let's go use it to define our sharing rule for
review records.
166
Securing and Sharing Data
Remember this page? We were last here when we defined our org-wide defaults.
2. In the Manage sharing settings for drop-down list, choose Job Application.
Choosing an object in this drop-down list allows us to focus in on the org-wide defaults and
sharing rules for a single object at a time rather than looking at all of them in a long page—a
really useful thing if you've got a large organization with several custom objects.
If you had chosen Review instead of Job Application, you would not have the option of creating
sharing rules, since you cannot create sharing rules for a detail record in a master-detail
relationship. However, since you chose Job Application, a Sharing Rules related list appears.
We'll use that to create the sharing rules that will apply to both the Job Application and the
Review objects.
Just as we talked about already, you can define a sharing rule only for a single public group,
role, or role with all of its subordinates. By default, the platform includes a default public group
that encompasses every user in your organization.
And that's it! We've just created a rule that shares reviews written and owned by any member
of the organization with all recruiters and hiring managers. Since reviewers and hiring managers
all need the power to read and update reviews, we handled everyone with a single sharing rule
and a public group.
To finish up here, go ahead and create two more sharing rules according to the following table:
167
Chapter 7: Securing and Sharing Data
The sharing rule for the Employment Website object is necessary to let hiring managers post
jobs, even though they will never be updating employment website records directly (the org-wide
defaults will prevent that). Without the rule, hiring managers can see employment website
records but cannot create job postings. This is because the Job Posting object is a junction
object (as you may recall from the last chapter), and the Employment Website object is one
of the Job Posting object's two master-detail relationships. Sharing access to a junction object
record is determined by a user's sharing access to both associated master records (in this case,
the associated position and employment website records) and the Sharing Setting option on
the relationship field. For example, if the sharing setting on both parents is Read/Write, then
the user must have Read/Write access to both parents in order to have Read/Write access to
the junction object.
In the sharing rule for the Employment Website object, we opted to use the existing Reviewers
public group. Doing this saved us a few clicks without granting access to any users who shouldn't
be looking at employment website records.
• Hiring managers need read and update access on position records on which they're the hiring
manager.
• Hiring managers need read access on candidate records on which they're the hiring manager.
• Interviewers need read access on the candidate and job application records for people they're
interviewing.
We didn't implement those required permissions with sharing rules because it was too hard
for us to come up with a consistent group of users who would need access to a particular set
of records. Really, this is where the job of the recruiter comes into play. A recruiter like Mario
Ruiz owns the position, candidate, and job application records for jobs that he's trying to fill,
and he also knows the hiring manager and interviewers who should be assigned to them.
168
Securing and Sharing Data
Fortunately, we have one final type of record-access setting that allows Mario to share specific
records with other specific users: manual sharing. With manual sharing, Mario can grant read
or read/write access on records that he owns to any other user, role, or public group. Although
it isn't automated like org-wide defaults, role hierarchies, or sharing rules, manual sharing gives
Mario the flexibility to share particular records with the ever-changing groups of interviewers
and hiring managers with whom he has to deal every day.
Since we own this candidate record, we get to see details about who else can see the record
and why. If we didn't own this record, there would be a message about not having sufficient
privileges.
Tip: If we wanted to view the names of each user who has access to the record rather
than just the names of the roles and public groups, we could click Expand List in this
page. Although the operation can take some time depending on the number of users
in our organization, it's helpful to determine whether we need to define a manual
sharing rule for a particular user or if he or she already has access.
2. Click Add.
3. In the Search drop-down list, choose whether we want to manually share the record
with a user, public group, role, or role and subordinates.
4. In the Currently Not Shared list, select the user, public group, or role that
should have access to the record, and click Add.
169
Chapter 7: Securing and Sharing Data
5. In the Access Level drop-down list, specify whether the user, public group, or
role should have read or read/write access to the record.
6. Click Save.
Not too hard! When we roll out our Recruiting app to users, we'll have to train our recruiters
to take these steps for the position, candidate, and job application records that their hiring
managers and interviewers need to access. Once this training is complete, we will have
implemented all of the required sharing and security settings that we discussed at the beginning
of the chapter—well done!
Both usability and data integrity are adversely affected by irrelevant data. The less irrelevant
data we display to users, the better off everyone will be. Not only can irrelevant data be confusing
and impede a user's efficiency, but it also makes he or she more prone to entering incorrect
values. By taking away unnecessary choices, we reduce the risk of making avoidable mistakes.
Although we've already put plenty of thought into our app's usability, there's always room for
improvement. We won't go into a detailed usability analysis here, but let's make two minor
modifications to get a feel for some of the ways you can improve the usability and data integrity
of your apps in the future.
The modifications we're going to make involve position records. Currently, each position
record displays the same data to hiring managers and recruiters, even though there are a few
items on the position record that are of no use to recruiters who create positions for departments
other than Development. For example, a recruiter who is creating a position for a Sr. Financial
Analyst would have no use for the Required Programming Languages section.
By the same token, there are some options on position records that have nothing to do with
technical positions, such as the Human Resources and Warehousing values in the Functional
Area picklist. Wouldn't it be nice if we could create two types of position records: one with
IT-related data for IT managers, and another for non-IT personnel?
Fortunately, we can with record types! Record types allow you to show different picklist values
and page layouts to different users based on their profiles.
170
Securing and Sharing Data
To address the issues discussed above, we'll create two position record types. The first position
record type will be for IT positions and will include the Required Programming Languages
section of the page layout. Additionally, it will exclude all of the options in the Functional
Area picklist except for Information Technology and Miscellaneous. The second position
record type will be for all non-IT positions and will include all of the Functional Area
picklist values except for Information Technology, but will omit the Required Programming
Languages section.
We'll give Recruiters the option of choosing either record type when creating a position, since
recruiters at Universal Containers work with every department, not just Development. However,
since our hiring managers all work in the Development department, we'll restrict them to only
creating positions that use the record type for IT positions.
Down the road, if you want to include hiring managers from other departments in your
recruiting app, you can reconfigure the record types on the Position object to let all hiring
managers choose which record type to use, or create more profiles. For now, though, let's use
our app the way it's currently set up, and focus our attention on learning record types.
The bottom of the screen lists all your profiles. Here is where we can determine which profiles
have access to this record type. All of them are selected by default, but we don't want hiring
managers to use this record type.
171
Chapter 7: Securing and Sharing Data
The Standard Position record type detail page appears. The page lists the picklist fields found
on the record type's associated page layout, the Position Layout.
Since this is the record type for all non-IT positions, let's remove Information Technology
from the Functional Area picklist.
12. In the Selected Values box, select Information Technology and use the arrows to
move it to the Available Values box.
13. Leave the Default drop-down list set to None, and click Save.
You're done creating your first record type, but it's not quite configured the way we want it.
While it omits the Information Technology value in the Functional Area picklist, it still
displays the Required Programming Languages section. We'll fix this later when we modify
the page layouts for our record types, but first we have to create one more record type.
Once again, the bottom of the screen lists your org's profiles, although this time they are
deselected by default. Let's make this the default record type for the Hiring Manager profile.
We'll also enable the record type for recruiters, but we won't make it the default for them.
7. Next to Hiring Manager, select the Enable for Profile and Make Default
checkboxes.
8. Next to Recruiter, select the Enable for Profile checkbox.
9. Click Next.
We are again given the option to apply different layouts to different profiles. We still need to
create the page layout for this record type, though, so we'll have to apply the page layouts later.
10. Leave the Apply one layout to all profiles radio button selected, and
select Position Layout in the adjacent drop-down list.
11. Click Save.
172
Securing and Sharing Data
Since this is the record type for all IT positions, let's remove all the options from the
Functional Area picklist except for Information Technology and Miscellaneous.
13. Use the arrows to move the values until the Available Values box only contains
Information Technology and Miscellaneous.
14. In the Default drop-down list, select Information Technology.
15. Click Save.
Both record types are now in place, and both are omitting the picklist values they're supposed
to omit. It's time to configure the page layouts for these record types.
We'll need a separate page layout for each record type. Lucky for us, we already have one page
layout for the Position object (Position Layout), so we just need to create one more.
Selecting the existing page layout creates a copy on which we can base our new page layout.
This saves us from having to create the layout from scratch.
5. In the Page Layout Name field, enter IT Position Layout, and click Save.
We're done creating our new IT position page layout. Now, let's edit both our new and original
page layouts so they display relevant data. Since we're on the IT Position page layout, we'll
start with that one.
This page layout already includes the Required Programming Languages section, so we don't
need to add that; however, we do want to add the Record Type field to the page layout so
users will instantly be able to tell what type of position record they're editing.
6. Select the Fields category in the palette, then drag the Record Type field to just
below the Last Modified By field.
7. Click Save.
Now, let's edit the Position Layout page layout. This is the layout we'll use for our Standard
Position record type, so we'll want to remove the Required Programming Languages section.
We'll want to add the Record Type field to this page layout as well.
5. Select the Fields category in the palette, then drag the Record Type field and drag
it to just below the Last Modified By field.
6. Click Save.
We're on the verge of finishing! There's just one more easy task to complete: assigning our
Position page layouts to our new record types.
Assigning page layouts is easy because you can make all of the assignments for an object on a
single page.
A table shows the Position page layout assignments for all of the different profile and position
record type combinations. In the table, you can select the profile and position record type
combinations you want to change. Use SHIFT+click to select a range of cells or CTRL+click
to select multiple cells at once. Use the drop-down list above the table to indicate the page
layout to which you want to reassign your selections.
5. Click the IT Position column heading. This selects all of the values in the IT Position
record type column.
6. Select IT Position Layout in the Page Layout To Use drop-down list.
7. Click Save.
We learned about the difference between object-, field-, and record-level security, and how
profiles and roles work together to first determine the objects and tabs that a user can possibly
use, and then the specific records that the user can actually access and edit. We also learned
174
Securing and Sharing Data
ways to set up other profile-based features like record types to improve both our data integrity
and our app's usability.
Let's now try it out for ourselves. To do so, we'll first have to define a number of users, and
then we can play around with creating records and seeing who has access to what.
175
Chapter 7: Securing and Sharing Data
* You'll need to create this review record because it isn't part of the sample import data.
Let's walk through the creation of Phil Katz. Then you can finish the other four users on your
own:
176
Securing and Sharing Data
able to log in! (For a real user, both Email and Username should generally have the same
value.)
Tip: When creating a new user, you are also required to create the user's community
nickname. The community nickname is used to identify the user in the Salesforce
CRM Ideas app, which is a community of users who post, vote for, and comment on
ideas. Consider it an online suggestion box that includes discussions and popularity
rankings for any subject. The community nickname can contain up to 40 alphanumeric
characters. For more information, see the Salesforce.com online help.
4. Click Save.
Now that we've created the Phil Katz user, let's give him ownership of the DBA position and
its associated job application and candidate records.
Tip: If you want to see more than just the Position Title field in this view, click
Edit next to the View drop-down list and add additional fields in the Select Fields to
Display section.
7. Click DBA.
8. Next to the Owner field, click Change.
9. Click the lookup icon and choose Phil Katz.
10. Click Save.
177
Chapter 7: Securing and Sharing Data
11. In the Job Applications related list, click the name of the listed job application and
repeat Steps 8-10.
12. Click the ID of the associated candidate on the Job Application detail page and
repeat Steps 8-10.
All done! Now create the other four users in Recruiting App Users on page 127 and assign
them ownership of the indicated records. To fully complete this, note that you'll have to create
Amy Lojack's review.
1. First log in as Mario Ruiz—verify that he can see and edit both positions, all three
candidates, all three job applications, and Amy Lojack's review. Verify that the New
buttons are there for all recruiting objects. Verify that he can create positions using
either position record type.
2. Log in as Melissa Lee—verify that she can view positions but that there's no New
button. Verify that she can't see any candidates, reviews, job applications, or
employment websites.
3. Log in as Ben Stuart—verify that he can view positions and that there's a New
button, but no record type selection. Verify that he can view but not edit employment
websites. Verify that he can't see any candidates. Verify that he can view job
applications, but not edit their lookup fields. Verify that he can view reviews and
that there's a New button. (What do reviews look like? Can he see the names of the
candidates and job applications on them?)
4. Log in again as Mario Ruiz—have him manually share read/write access on the SW
Engineer position with Ben. Have him manually share read access on the candidate
with Melissa and Ben. Have him manually share read access on the job application
with Melissa and read/write access on the job position with Ben.
5. Log in again as Melissa Lee—verify that she can now see the candidate and job
application that Mario just shared with her but that she can't see the candidate's
social security number. Have her create a review for that candidate.
6. Log in again as Ben Stuart—verify that he can edit the Jr. Software Engineer position.
Verify that he can read and update Melissa's review. Verify that he can update the
job application to suggest that they hire the candidate.
How did we do? If all of these use cases worked correctly, you've just successfully set up security
and sharing for our Recruiting app! However, there is one critical security-related issue that
178
Securing and Sharing Data
we have yet to address: who will be responsible for overseeing the operation of the Recruiting
app and its related data when the app goes live?
• A hiring manager is retiring and has forty open positions that need to be transferred to
another manager
• A current Recruiting app user needs immediate access to private data owned by another
user who happens to be on vacation
• Duplicate records have piled up in the Recruiting app and need to be removed
• A new employee just got hired and needs access to the Recruiting app
To handle these situations, someone might need to override the security and sharing
configurations we just created. Who should have such powers within our app, and how can
these powers be granted?
Obviously, your company's primary Salesforce.com administrator can handle just about any
issue that users may encounter in Salesforce.com. Primary administrators are assigned to the
System Administrator profile, which automatically grants several global administrative
permissions, including:
• “View All Data”—View all data owned by other users in your organization
• “Modify All Data”—Modify all data owned by other users in your organization, mass
update and mass delete records, and undelete records that other users deleted
• “Customize Application”—Customize just about anything in Salesforce.com, from page
layouts to the data model
• “Manage Users”—Add and remove users, reset passwords, assign profiles, and more
For smaller companies, it makes sense to have a single administrator be the “go-to” person for
all Salesforce.com issues. But for medium to large companies, assigning all Salesforce.com
responsibilities to one person is not practical, especially when you consider that a company can
run its entire business in the cloud using a different Force.com app to suit each of its business
needs. This could add up to dozens of apps and hundreds or thousands of users! Your primary
Salesforce.com administrator will likely go insane unless other folks can help with the
administration. At the same time, every administrative privilege you grant increases the risk
179
Chapter 7: Securing and Sharing Data
of exposing your company's sensitive data, so you need precise control over the amount of
access you enable.
To preserve both your administrator's sanity and your company's security, the Force.com
platform provides two ways to quickly delegate restricted data administration access: object-level
permissions and delegated administration groups.
The keyword here is “all.” When you select “View All” or “Modify All” next to an object on a
profile edit page, you grant those users access to all records of that object regardless of the
sharing and security settings. In essence, the “View All” and “Modify All” permissions ignore
the sharing model, role hierarchy, and sharing rules that the “Create,” “Read,” “Edit,” and
“Delete” permissions respect. Furthermore, “Modify All” also gives a user the ability to mass
transfer, mass update, and mass delete records of that specific object, and approve such records
even if the user is not a designated approver. These tasks are typically reserved for administrators,
but because “View All” and “Modify All” let us selectively override the system, responsibilities
that are usually reserved for the administrator can be delegated to other users in a highly
controlled fashion.
Note: We'll learn more about approving records in the next chapter. Other
administrative actions, such as mass updates, are covered in the Salesforce.com online
help.
You may wonder if the “View All” and “Modify All” object-level permissions are similar to
the “View All Data” and “Modify All Data” global administration permissions discussed above.
It is true that they all ignore the sharing model, hierarchy, and sharing rules, but bear in mind
that object-level permissions only apply to records of a specific object, whereas global
administration permissions apply to records of every object in your organization. As a rule of
thumb, when global administration permissions are too permissive for a particular profile, use
the object-level permissions instead to control data access on an object-by-object basis.
180
Securing and Sharing Data
Tip: To quickly see a list of the profiles with permissions that override the sharing
model, click Your Name ➤ Setup ➤ Security Controls ➤ Sharing Settings, then
select an object in the Manage sharing settings for drop down list. The page displays
a Sharing Overrides related list that shows the profiles that can access the object, as
well as the global and object-level permissions that are enabling the access.
Because we already applied object-level permissions when we created the Recruiter profile,
there's no need to walk through the process again here; however, you can probably imagine
other ways in which the “View All” and “Modify All” permissions might be useful for this app.
For example, as we discussed before, certain laws may require your company to keep all position,
candidate, and job application records for a specific amount of time. This law is why we opted
not to give recruiters the ability to delete those records. When that legal time limit expires,
though, your company may want to hire a contractor who specializes in data cleansing to
remove old recruiting data from the system. By creating a profile with the “Modify All”
object-level permission on positions, candidates, and job applications, you can quickly give the
contractor the permissions needed to get the job done without exposing the rest of your
company's data.
• Creating and editing users and resetting passwords for users in specified roles and all
subordinate roles
• Assigning users to specified profiles
• Logging in as a user who has granted login access to an administrator
• Managing custom objects created by the primary administrator
181
Chapter 7: Securing and Sharing Data
Let's define a delegated administration group in our Recruiting app that enables its members
to manage our Recruiting app's users and make adjustments to the app's custom objects without
having access to all of the other data in Salesforce.com.
The Enable Group for Login Access option allows the delegated administrators in
this group to log in as a user who has explicitly granted login access to administrators for a
specific period of time. This can be useful for troubleshooting problems that might arise for
the user.
5. Click Save.
The Delegated Group detail page appears. We can use the Delegated Administrators related
list to specify the users to include in this group.
Each delegated administration group can have up to five members, but we're only going to
include our Recruiting Manager in this group, due to the focus of our app.
8. Click Save.
We're back on the Delegated Group detail page. The User Administration related list lets us
specify the kinds of users this group can manage.
Instead of selecting individual users to manage, we'll select them by their roles. For each role
we select, its subordinate roles are automatically selected too. (Flip back to the Universal
Containers role hierarchy on page 127 if you can't remember which roles are subordinate.) We
182
Securing and Sharing Data
don't want to let members of this group administer the Salesforce.com accounts of executives
at Universal Containers, but the group should be able to administer the Recruiting app for
recruiters, directors, managers, and their subordinates.
The Assignable Profiles related list lets us specify the profiles this group can assign to the users
they manage. Note that delegated administrators cannot modify these profiles; they can only
assign users to them.
The Custom Object Administration related list lets us specify the custom objects that delegated
administrators of this group can administer. The delegated administrators can manage just
about every aspect of the custom object, such as modifying page layouts, adding fields, and
even deleting the object; however, they cannot set permissions for the custom object on profiles,
manage workflow and sharing for the object, and modify relationships to other objects.
Let's give the members of this delegated administrator group (in this case, Phil) the ability to
modify the Position object. That way, if position records need another field or hiring managers
request another record type in the future, Phil can handle it. (Of course, we'll also want to
warn Phil that he should be careful not to delete the Position object altogether—custom object
administrative rights give him that power as well!)
183
Chapter 7: Securing and Sharing Data
Notice that the Edit link appears next to any user assigned to a role or subordinate role for
which our delegate administrator group can manage users. The Edit link does not appear to
users assigned to other roles, such as Cynthia Capobianco, the CEO.
You'll also see the New User, Reset Password(s), and Add Multiple User(s) buttons are now
available to Phil. Let's see what happens if Phil adds a new user.
The User Edit page appears. At first glance, this page looks just like the User Edit page we
saw when we added users while logged in as the system administrator. If you look closely at
the options available in the Role and Profile drop-down lists, though, you'll notice a
difference—the options are limited to what we specified when we created our delegated
administration group. For example, Phil can't create a user with an executive role, nor can he
assign a user to any profile other than Recruiter, Hiring Manager, or Standard Employee.
We don't need to create any more users right now, so just click Cancel.
The last thing to verify is Phil's ability to modify the Position object.
We see that the Edit and Del links are available next to the Position object. This means that
Phil now has the ability to both edit and delete the Position object. Our testing is complete!
Summing Up
This chapter has covered quite a bit of ground! We discussed the differences between object-,
field-, and record-level security. We learned how profiles and roles work together to first
determine the objects and tabs that a user can possibly use, and then the specific records that
the user can actually access and edit. We also discovered ways to set up other profile-based
features like record types to improve both our data integrity and our app's usability. Finally,
we tested everything, and delegated the administration of our Recruiting app in an efficient
and secure way. Now that we've got security squared away, let's go incorporate some business
logic into our app with workflow rules.
184
Chapter 8
Using Custom Workflow and Approval Processes
In this chapter ... Now that we've set up all our custom objects and made sure
they're secure, it's time to start looking at ways we can make
• Introducing Workflow our Recruiting app more powerful.
• Workflow in Our
Recruiting App Up to this point, we've created little more than a glorified
• Creating Workflow Rules database—it holds all of the information we need and allows
us to search for records based on various criteria, but it
That Assign Tasks
doesn't help our recruiters and hiring managers perform the
• Creating a Workflow Rule functions of their jobs more effectively. There's no
That Updates Fields automation that lets a recruiter know when the status of a
• Creating a Workflow Rule candidate has changed or when a new position has been
That Sends Email Alerts entered into the system.
• Introducing Approvals
• Summing Up Indeed, when any changes are made, users have to remember
to notify one another of the change or else rely on the fact
that others will find the updates on their own. Neither
solution is practical for the long term, and both invite the
possibility that the Recruiting app won't be adopted
consistently by all the employees at Universal Containers.
How can we build processes into our app so that users won't
need to rely on manual methods of communication to inform
others of changes?
185
Chapter 8: Using Custom Workflow and Approval Processes
Introducing Workflow
Workflow is a Force.com platform business-logic engine that allows us to automatically send
email alerts, assign tasks, or update field values based on rules that we define. Any time that
changes to a record meet the conditions in a workflow rule, the platform automatically performs
any actions associated with the rule.
For example, let's say Ben Stuart, a software development manager, has decided to extend an
offer to Ethan Tran, a bright young candidate who's interested in the Jr. Software Engineer
position. At Universal Containers, it's a recruiter's job to extend offers, but in this case, Mario
Ruiz, the recruiter responsible for the Jr. Software Engineer position, doesn't know whether
or not Ben has made a decision unless Ben emails or calls him directly.
Instead of relying on Ben to remember to tell Mario, we can set up a simple workflow that
triggers the assignment of the appropriate task whenever the status on a job application record
is set to Extend an Offer or Rejected. As soon as Ben changes the status of the candidate's job
application, workflow creates the appropriate task and sends Mario a notification email, as
shown in the following diagram.
Pretty powerful, isn't it? In general, if we can come up with a standard rule that specifies when
a particular event should happen, we can make it happen automatically with workflow. Workflow
186
Using Custom Workflow and Approval Processes
is one of the secret ingredients that's going to transform our Recruiting app from a glorified
database into a fully functional tool that everyone finds useful.
Now that we've got a general idea of what workflow's all about, let's take a closer look at the
individual components that make up workflow: rules, tasks, field updates, and alerts.
Every workflow rule must be based on a single object you choose when you define the rule.
This object influences the fields that are available for setting workflow activation criteria.
For example, if we define a workflow rule for the Job Application object, we'll be able to set
workflow activation criteria based on the values of fields like Job Application Number
and Status. We can also set workflow activation criteria based on standard fields, like Record
Owner or Created Date, as well as fields based on the currently active user when a rule is
evaluated, such as their Role or Time Zone.
We'll look at all the ways that we can set workflow activation criteria when we get to building
our own workflow rules a little later. For now, just understand that the platform makes it very
easy to create detailed workflow rules that target specific situations.
187
Chapter 8: Using Custom Workflow and Approval Processes
Note: A fourth type of action, a workflow outbound message, sends data to an external
Web service, such as another application in the cloud. Outbound messages are used
primarily with application programming interfaces, so we won't be using them in this
chapter.
A workflow rule can include any combination of these actions when the rule is triggered. For
example, one rule might send out an alert and update two fields on a particular record. The
action that one workflow rule takes can also trigger the execution of another workflow rule.
We've already talked about one instance where workflow will give us a big advantage:
automatically assigning a task to a recruiter when the status of a job application record changes
to Reject or Extend an Offer. This will be a great start, but what else can we do?
If we look back at our last chapter on security and sharing, recall that we wanted to grant both
recruiters and hiring managers permission to create new positions, but that ultimately we always
wanted a recruiter to own those records because filling them is the recruiter's job responsibility.
We hinted in the security and sharing chapter that we could accomplish this with workflow,
and indeed we can! We'll simply need to use a workflow field update to change the record
owner of a position record to a recruiter if it was originally created by a hiring manager. To
prevent a single recruiter from getting overloaded with all these additional positions, we'll also
use another platform feature, queues, to divvy up the orphaned position records fairly. We'll
place the record in a queue of other position records without owners, and then let individual
recruiters claim the positions they want.
188
Using Custom Workflow and Approval Processes
For a third way of using workflow, let's think about how position availability is advertised
throughout Universal Containers. Like many organizations, Universal Containers prefers to
fill positions with employee referrals, but employees often aren't aware of which positions are
currently open. We can use a workflow alert to automatically send email to every employee
whenever a new position opens up. This way employees learn about positions as they become
available and can immediately think of friends and family members who might be interested.
Sound good? While there are probably many more ways to use workflow to build a killer
on-demand Recruiting app in the cloud, let's stick with these three for now since they'll give
us a good example of each of the three types of workflow actions that are available. To
summarize what we'll be building:
1. A workflow task that assigns a task to a recruiter when the status of a job application
changes to Rejected or Extend an Offer
2. A workflow field update that reassigns ownership of a position that's created by a
hiring manager to a queue of position records without owners, so that individual
recruiters can claim ownership of the positions they want
3. A workflow alert that sends an email to every employee when a new position is
created
189
Chapter 8: Using Custom Workflow and Approval Processes
The first thing we need to do is select the object that will be associated with our workflow rule.
As we talked about earlier, every workflow rule must be associated with a single object to
determine the fields that we can use to set criteria. Since we need to trigger this workflow rule
when the Status field of a job application record is set to “Reject,” we need to select Job
Application here:
4. In the Select object drop-down list, choose Job Application, and click Next.
Now use the Evaluation Criteria area to specify when this rule should be evaluated. We can
choose When a record is created, or when a record is edited and did
not previously meet the rule criteria (which repeatedly triggers the rule every
time a record is saved only until the rule's criteria are met), Only when a record is
created (which ignores updates to existing records), or Every time a record is
created or edited (which repeatedly triggers the rule every time the record is saved).
Since we don't want to assign duplicate tasks to a recruiter every time the record is saved, we'll
choose the first option.
To finish up defining the rule, we need to specify the conditions that will trigger execution of
the rule's associated actions. We can do this by defining a set of criteria that trigger the workflow
rule when met, or we can create a formula that triggers the workflow rule if it evaluates to
True. While creating a formula provides more flexibility, setting the criteria is easier. For this
rule, we can achieve our objective by setting the criteria, so let's do that.
Every workflow rule requires at least one row of filter criteria, but we can set as many filters
as we want using additional rows.
190
Using Custom Workflow and Approval Processes
At this point, we've just defined our “Send Rejection Letter” workflow rule. If we canceled out
of the workflow wizard and clicked Your Name ➤ Setup ➤ Create ➤ Workflow & Approvals
➤ Workflow Rules, we'd see it in the list view. However, because workflow rules aren't all
that useful without an associated action, the workflow wizard takes us directly to a screen where
we can define the “Send Rejection Letter” workflow task. Let's work through that now.
191
Chapter 8: Using Custom Workflow and Approval Processes
You can either define actions that occur immediately after the condition is met, or you can
define actions that occur before or after a certain amount of time has elapsed (for example,
seven days before the value of the Hire By field, or three days after the workflow rule is
triggered). We'll talk more about these time-dependent workflow actions a little later. For now,
we just need to define a single workflow task that executes as soon as our rule criteria is met:
1. In the Immediate Workflow Actions area, click Add Workflow Action and select
New Task.
Did you notice that the Object field is already filled in with Job Application? Here's where
we saved ourselves a couple of clicks—if we'd started building our workflow task before our
workflow rule, we would have needed to specify the object with which the task would be
associated. That's because, like workflow rules, workflow actions need to be associated with a
single object.
In this case, we got to skip a page because the object with which a workflow action is associated
must match the object of a workflow rule that uses it. For example, if we had a workflow rule
associated with the Candidate object, any task, field update, or alert that's triggered by our
candidate workflow rule must also be associated with the Candidate object. Because we started
building our “Send Rejection Letter” workflow task in the wizard right after defining our “Send
Rejection Letter” workflow rule, the platform knew that the object associated with our task
had to match the rule that we'd already built. That's why our new workflow task is already
associated with the Job Application object.
The rest of the fields on this edit page make up the template for any “Send Rejection Letter”
tasks that our workflow rule will generate.
192
Using Custom Workflow and Approval Processes
Here we can choose the assignee of the task either by specifying a particular user, role, or the
owner of the job application record that triggered the workflow rule in the first place. Since
recruiters always own the job application records of the positions that they're responsible for,
and recruiters are responsible for sending rejection letters at Universal Containers, let's select
the record owner:
Caution: If you thought that choosing the Recruiter role for the Assigned To field
might have been another valid option, be careful. If the assignee of a workflow task is
a role that contains more than one assigned user, the person who triggered the rule
will become the task assignee instead. For this reason, you never want to assign
workflow tasks to roles unless you're sure that only one user will ever be assigned to
them at a time.
This Due Date setting will give our recruiters two days to notify the candidate after they're
first assigned the task.
The Notify Assignee checkbox allows us to send an email to the assignee as soon as the
task is created by the workflow rule. This ensures that the assignee knows about the task without
having to log in to the application on a regular basis, so let's select it.
193
Chapter 8: Using Custom Workflow and Approval Processes
At this point, we finally get to see the detail page for the workflow rule that we just created.
It includes the workflow rule criteria and a list of the associated actions. The only thing that
remains to be done is to activate the rule.
All done! We've just created our first workflow rule and task. You'll find that the remaining
workflow actions all operate in a very similar way, so we'll speed through the rest of them,
focusing just on the fields and options that are unique to each. First, let's finish up our second
workflow rule that assigns a task by quickly creating the “Extend an Offer” workflow rule.
Try It Out: Creating the “Extend an Offer” Workflow Rule and Task
To wrap up our first use case, we need to create another workflow rule for when the status of
a job application is set to Extend an Offer. This rule and task are almost identical to the “Send
Rejection Letter” workflow rule and task, so we'll just list the values that you'll need in the
following two tables.
194
Using Custom Workflow and Approval Processes
Table 35: Values for Creating the “Extend an Offer” Workflow Rule
Field Value
Object Job Application
Name Extend an Offer
Description Make an offer when a hiring manager changes
the status of a job application to Extend Offer.
Evaluation Criteria When a record is created, or when a record is
edited and did not previously meet the rule
criteria
Filter Criteria Status equals Extend an Offer
Table 36: Values for Creating the “Extend an Offer” Workflow Task
Field Value
Assigned To Job Application Owner
Subject Extend an Offer
Due Date Rule Trigger Date plus 1 days
Status Not Started
Priority High
Notify Assignee? Yes
All done! Make sure the “Extend an Offer” rule is also activated, and let's go try out one of
our new workflow rules.
1. Click the Job Applications tab, and select a job application record.
2. Click Edit, and change the Status field to Rejected.
3. Click Save.
The Send Rejection Letter task automatically appears in the Open Activities related list on
the Job Application detail page, as shown in the following screenshot.
195
Chapter 8: Using Custom Workflow and Approval Processes
Figure 68: Open Activities Related List on Job Application Detail Page
Pretty neat, don't you think? Not only that, but if you check in the recruiter's email inbox, he
should have received an automatically-generated email notification that looks like the following:
Caroline Roth has assigned a new task to you: Send Rejection Letter
Job Application: JA-00007 Due Date: 2/11/2007
For more details on this task, click on the link below:
https://na1.salesforce.com/00Tx04123s5k1
The link in the email message takes the recruiter directly to the task detail page, where he or
she can locate the contact information of the candidate and update the task status after the
task is completed. The task also shows up in the My Tasks area on the recruiter's Home tab,
and a reminder message will pop up in another day if the recruiter hasn't yet changed the task's
Status to Completed. Suddenly, our Recruiting app has become a lot more interactive and
powerful!
196
Using Custom Workflow and Approval Processes
ownership of the positions they want. But before we jump ahead of ourselves, let's stop a
moment. Just what, exactly, is a queue?
Introducing Queues
Much like a collection of items in a lost and found drawer, a queue is a collection of records
that don't have an owner. Users who have access to the queue can examine every record that's
in it and claim ownership of the ones they want.
Queues are traditionally used in sales and support organizations to distribute new leads and
support cases to the employees who have the most availability. Because the platform natively
supports queues for Leads, Cases, and any custom object, we can create a queue for the
Recruiting app's Position object.
Notice here that if recruiters@universalcontainers.com was a real email distribution list that
went to all recruiters, we wouldn't need to select Send Email to Members. We do it here
only because recruiters@universalcontainers.com is a fake email address and can't be used for
testing later. The following table outlines the options you have for notifying queue members
when new records are added to the queue:
Table 37: Options to Specify How Queue Members are Notified of New Records
197
Chapter 8: Using Custom Workflow and Approval Processes
Send Email to Members Because a queue email is not The specified queue email
Checkbox Selected specified, individual queue address and individual queue
members are always notified, members are notified.
regardless of the Send Email
Note that if an individual
to Members checkbox.
queue member also receives
emails sent to the specified
queue email address, they'll
receive duplicate notifications.
6. In the Supported Objects section, move Position into the Selected Objects list.
198
Using Custom Workflow and Approval Processes
As you can see, a single queue can handle multiple objects—the platform allows you to do this
so that you don't have to define multiple queues for the same group of users.
7. In the Queue Members section, select Roles and Subordinates from the Search
drop-down list.
8. Move Role and Subordinates: Recruiting Manager to the Selected Members list.
9. Click Save.
199
Chapter 8: Using Custom Workflow and Approval Processes
Perfect! We've just defined a new queue that can act as a temporary owner for all of the position
records that are created by hiring managers. Whenever a position is placed in the queue, all
recruiters are notified, and the appropriate person can claim ownership. All we need to do now
is define the workflow rule that places those position records into the queue.
While we know that recruiters should almost always own position records, we don't want to
impede the organization if there's a special case in which a non-recruiter should own the record
instead. Let's choose to evaluate this rule only when a record is created so that if an exception
needs to be made, the workflow won't supersede any changes that were made by a recruiter.
Finally, we need to make sure that this rule is initiated whenever a position record is created
by someone who isn't a recruiter or a recruiting manager. We can specify this filter criteria in
a single row by using a comma in the Value column as follows:
Now let's create the field update action for this workflow rule:
9. In the Immediate Workflow Actions area, click Add Workflow Action, and select
New Field Update.
10. In the Name text box, enter Reassign Position to Queue.
11. In the Description text box, enter Assign the Position to the
Unclaimed Positions Queue.
200
Using Custom Workflow and Approval Processes
Once you make a selection in this drop-down list, new options appear just below depending
on the selection that you made.
Not too hard! Before we leave this workflow rule behind, though, let's give it a second workflow
action—one that ensures that no positions will languish in the queue without being claimed
by a recruiter. This time, we'll use a time-dependent workflow action.
For example, the goal of reassigning position records to the Unclaimed Positions queue is to
have the appropriate recruiter take ownership. However, there might be situations in which a
position is placed in the queue and no recruiter claims it. Rather than leaving the position to
languish unclaimed in the queue, we can define a time-dependent workflow action that alerts
the recruiting manager if no recruiter claims a position record within a certain number of days.
Because this action only takes place while the workflow condition remains true (that is, while
the position is owned by a non-recruiter), the manager will only be alerted when necessary.
201
Chapter 8: Using Custom Workflow and Approval Processes
Before we can define a time-dependent workflow task, we first must specify a time trigger.
Time triggers define when the time-dependent workflow actions should fire.
In this case, we want our recruiting manager to be notified three days after a position has been
assigned to the Unclaimed Positions queue.
2. Use the text box and drop-down lists to specify 3 Days After Rule Trigger Date.
3. Click Save.
Our time trigger is now listed in the Time-Dependent Workflow Actions area. The Add
Workflow Action drop-down button is now active, and we can define our workflow task as
usual.
4. In the Time-Dependent Workflow Actions area, click Add Workflow Action and
select New Task.
5. In the Assigned To field, select the Recruiting Manager role.
Note: Remember, workflow tasks should only be assigned to a role if you're confident
that only one user will ever be assigned to that role at a time. If the role contains
multiple users, the owner of the workflow rule is assigned the task.
Since this workflow action won't fire until three days after the original Rule Trigger Date,
making the Due Date four days after the Rule Trigger Date gives the recruiting manager one
additional day to assign the position to a recruiter.
Almost done! At this point, all we need to do is activate our workflow rule. However, if you
click the Activate button now, an error message appears saying that the Default Workflow
User must be set before activating the rule. What's that?
The Default Workflow User is the user who should be assigned as the owner of a workflow
action if the user who originally triggered the rule is no longer active. This setting is required
if you want to use time-dependent workflow actions. To set it:
13. Click Your Name ➤ Setup ➤ Create ➤ Workflow & Approvals ➤ Settings.
Note: If you click Activate without previously setting the Default Workflow User
and then click OK in the error dialog, you're sent directly to the Workflow & Approvals
Settings page.
14. Set the Default Workflow User field to any user in your organization. In most
cases, it's best to choose a system administrator.
15. Click Save.
Note: If you reached the Workflow & Approvals Settings page by clicking Activate
and then OK in the error dialog, clicking Save also automatically activates your
workflow rule.
16. Click Your Name ➤ Setup ➤ Create ➤ Workflow & Approvals ➤ Workflow
Rules.
17. Click Activate next to the Assign Position to Recruiter workflow rule.
To try it out, simply make sure that you're logged in as a hiring manager and create a new
position. As soon as you return to the detail page for the position, you'll see that the Unclaimed
Positions Queue has automatically been assigned as the record owner, and that any user assigned
to the Recruiter or Recruiting Manager role will have received an email notification.
203
Chapter 8: Using Custom Workflow and Approval Processes
To actually view the contents of the queue, click the Positions tab, and choose Unclaimed
Positions Queue from the View drop-down list. Any recruiter or recruiting manager can click
the Accept button on this page and take ownership of the new position.
Although our Assign Unclaimed Position Record to Recruiter workflow task won't be activated
for another three days, we can see that it's currently scheduled to fire by checking out the
workflow queue. This queue lists all of the time-dependent workflow actions that are scheduled
for the future. To view it:
As soon as a recruiter takes ownership of the new position record, this task is deleted from the
workflow queue. Pretty slick, isn't it?
Now let's build one final workflow rule so we can see how to create a workflow email alert.
For this workflow rule, there's a step that we'll need to handle first: we need to design a template
for what the email alert should look like.
204
Using Custom Workflow and Approval Processes
To personalize the content of an email template, we can use merge fields to incorporate values
from records that are stored in the system. For example, if we wanted to address an email
recipient by their first name, we could write an email template as follows:
Dear {!Contact.FirstName},
...
In this example, {!Contact.FirstName} is a merge field that brings in the first name of
the contact to whom the email is addressed, so an email to John Smiley would read:
Dear John,
...
For our workflow alert, we can build an email template to notify users of new positions that
have been added to the system. We can use merge fields to include information from the
position record, such as its title and the required skills. Let's go do that now, and then we can
get back to finishing up our final workflow rule.
Here you should see a list of all the email templates that have already been defined for your
organization, including several sample templates from salesforce.com.
We can choose to create a text, HTML, or custom email template. HTML and custom email
templates are the same except that HTML templates allow you to specify a letterhead to give
your email the same look and feel as other emails from the same source.
205
Chapter 8: Using Custom Workflow and Approval Processes
Note: A fourth option, Visualforce, lets developers create email templates using
salesforce.com's tag-based markup language. We'll touch on Visualforce in Chapter
10.
To keep things simple, we'll just stick with a plain text email for now.
The New Template page allows us to define the email template itself. The gray area near the
top is where we'll generate the merge field codes for the fields in the email template below it,
so let's skip past it for now and start with the Folder drop-down list.
The Unfiled Public Email Templates folder is a standard, public folder available in every
organization. By keeping the email template in a public folder, it'll be available to other users
who have permission to view and edit email templates.
6. In the Email Template Name text box, enter Recruiting App: New
Position Alert.
Tip: To help keep your email templates organized, it's a good idea to preface any
template name with the name of the app that uses it. Or, even better, you can create
a public email template folder with the name of the app, such as Recruiting App
Templates, and file all the relevant email templates in it.
7. In the Encoding text box, accept the default of General US & Western Europe
(ISO-8859-1, ISO-Latin-1).
8. In the Description text box, enter Send update email to all
Universal Containers employees.
Now we get to the heart of our email template—the email's subject and body text.
We want to put the title of the new position in the subject of our email, so we'll need to use
our first merge field here, just after the colon in our subject. To get the proper code, we'll have
to go back to the gray merge field area near the top of the page.
10. In the Select Field Type drop-down list, choose Position Fields.
Although there are many objects to choose from in the Select Field Type drop-down
list, because we're creating an email template for a workflow rule, we're limited to the fields
for the object that will be associated with that workflow—in our case, Position. That's because
the workflow rule that uses this email template won't know about any individual records other
than the position record that triggered the rule's execution. If we put in fields from another
object, they'd be left blank in our email, because there wouldn't be a record from which to pull
the values.
In the Copy Merge Field Value text box, a merge field code appears for Position Title.
We can cut and paste it to the end of our subject line so the subject now looks like this: New
207
Chapter 8: Using Custom Workflow and Approval Processes
12. In the text area just below the Subject text box, enter the following text:
Title: {!Position__c.Name}
Functional Area: {!Position__c.Functional_Area__c}
Location: {!Position__c.Location__c}
Job Description
{!Position__c.Job_Description__c}
Responsibilities
{!Position__c.Responsibilities__c}
Skills Required
{!Position__c.Skills_Required__c}
Educational Requirements
{!Position__c.Educational_Requirements__c}
If you know of anyone great who might be able to fill this role, please
contact the hiring manager, {!Position__c.Hiring_Manager__c}.
Thanks!
That's it for our email template. Now that it's done, we're ready to create our New Position
workflow rule and alert.
Try It Out: Creating the New Position Workflow Rule and Alert
Now that we've built our email template, we're ready to build the workflow rule and email alert
that use it. By now this procedure should be very familiar to you:
208
Using Custom Workflow and Approval Processes
We only want this rule to execute once, whenever a position record's status is set to Open -
Approved.
Now let's create the email alert for this workflow rule:
9. In the Immediate Workflow Actions area, click Add Workflow Action, and select
New Email Alert.
10. In the Description text box, enter Email New Position Alert.
11. Next to the Email Template field, click the lookup icon ( ), and select Recruiting
App: New Position Alert.
We want to send this email to everyone at Universal Containers, but for this workflow rule
there's no obvious way of doing that. We can work around this by relying on our role hierarchy
and sending the email to everyone in the CEO role and its subordinates.
12. In the Recipient Type Search field, choose Role and Subordinates.
13. In the Available Recipients list, select Role and Subordinates: CEO and click Add.
14. Click Save.
15. Click Done.
16. Click Activate.
And that's all there is to it! To test out this workflow rule, all you need to do is create a new
position record with a Status value of Open - Approved. Within a few seconds, all users
within your organization will receive an email letting them know that a position has just been
created. Go ahead—try it!
209
Chapter 8: Using Custom Workflow and Approval Processes
Introducing Approvals
Now that we've just made a handful of workflow rules, let's take a look at another business
logic tool that the platform provides: approval processes.
Approval processes allow you to specify a sequence of steps that are required to approve a new
record. Each step allows one or more designated approvers to accept or reject a record. The
steps can apply to all records included in the process, or just to records that meet certain
requirements. Like workflow, approval processes also allow you to specify actions—like sending
an email alert, updating a field value, or assigning a task—that should occur whenever a record
is approved, rejected, first submitted for approval, or recalled.
210
Using Custom Workflow and Approval Processes
For example, suppose your organization has a three-tier process for approving expenses:
submitted expenses that are less than $50 are automatically approved, those over $50 must be
approved by a manager, and those over $5,000 must also be approved by a Vice President. For
this example, you can define an approval process that specifies the following:
• If an expense record is submitted for approval, lock the record so that users cannot edit it
and change the status to “Submitted.”
• If the amount is $50 or less, automatically approve the request.
• If the amount is greater than $50, send an approval request to the direct manager.
211
Chapter 8: Using Custom Workflow and Approval Processes
• If the amount is greater than $5,000 and the first approval request is approved, send an
approval request to the Vice President.
• If all approval requests are approved, change the status to “Approved” and unlock the record.
• If any approval requests are rejected, change the status to “Rejected” and unlock the record.
For our recruiting app, we're going to define a similar approval process to submit new positions
for approval. We want to make sure that a manager approves any position that his or her
employee creates, and that any position with a minimum salary of more than $150,000 is
approved by the CEO. Let's get started.
For this approval process, the only preliminary step we need to do is define an email template
that can be used to notify the designated approver that he or she has a pending approval request.
Table 38: The “Recruiting App: New Position Requires Approval” Email Template
Parameter Value
Template Type Text
Available For Use Selected
Email Template Recruiting App: New Position Requires Approval
Name
Encoding General US & Western Europe (ISO-8859-1, ISO-LATIN-1)
Description Send notification email to designated approver
when new position record requires approval.
212
Using Custom Workflow and Approval Processes
Parameter Value
Email Body A new position record has been submitted for
your approval. Please visit the link below and
either approve or reject it.
{!Position__c.Link}
Thanks!
There are two different wizards that we can use to create a new approval process: a Jump Start
Wizard and the Standard Setup Wizard. The Jump Start Wizard sets several default values
for us and only requires input for the most crucial fields: the approval assignment email template,
filter criteria to enter the approval process, and the designated approvers. The Standard Setup
Wizard, on the other hand, allows us to configure every possible option for our approval process.
We'll stick with it for now so we can take a look at all of the options that are available.
3. From the Create New Approval Process drop-down button, choose Use Standard
Setup Wizard.
4. In the Process Name field, enter Approve New Position.
5. In the Description field, enter Ensure that a manager approves any
position that his or her employee creates, and that any
position with a minimum salary of more than $150,000 is
approved by the CEO.
6. Click Next.
After entering the name and description, our next step is to specify the conditions that should
be used to determine which positions need approval. As with workflow rules, we can do this
by either defining a set of criteria or creating a formula. In this instance, let's define the criteria
so that all positions created by a user other than the CEO must get approved by at least a direct
manager.
213
Chapter 8: Using Custom Workflow and Approval Processes
7. In the first row of filter criteria, select Current User: Role not equal to CEO.
8. Click Next.
9. From the Next Automated Approver Determined By drop-down list, select
Manager.
The Manager field is a standard field on the User object that designates the user's manager.
The field establishes a hierarchical relationship between users, which prevents you from selecting
a user that directly or indirectly reports to his or herself. This manager will be the designated
approver for the first step of our approval process.
Alternatively, you could have selected the Create New Hierarchical Relationship Field option
in the drop-down list to define a new custom hierarchical relationship lookup field on the fly.
The hierarchical relationship field type is specifically designed for the User object, and mimics
the behavior of the standard Manager field by associating one user with another without
indirectly associating that user to him or herself. For this approval process, though, the standard
Manager field is perfect, so let's move on.
11. In the Record Editability Properties area, choose Administrators ONLY can
edit records during the approval process.
Record editability allows you to specify whether a record that's been submitted for approval
can be edited by the approver before being approved. Since we don't want managers to change
the positions that a hiring manager or recruiter creates without alerting the owner, we'll only
let administrators perform edits while a record is in our approval process.
214
Using Custom Workflow and Approval Processes
13. In the Approval Assignment Email Template lookup field, select Recruiting
App: New Position Requires Approval.
14. Click Next.
Our next step in defining the approval process is specifying which fields should be displayed
on the Approver page layout, which the approver sees when he or she approves or rejects a
record. Each approval process has its own page layout, and, unlike other page layouts, the
Approver page layout can only be configured from within its approval process.
We can display any Position object fields on the Approver page layout, but since we've restricted
the editability of the position record while it's in the approval process, these fields can't be
edited by the approver until the record is approved or rejected.
15. Move the following fields from Available Fields to Selected Fields:
• Position Title
• Owner
• Hiring Manager
• Type
• Location
• Hire By
• Job Description
• Min Pay
• Max Pay
215
Chapter 8: Using Custom Workflow and Approval Processes
On this page we can also specify whether approval history information should be displayed on
the Approver page layout. This information shows whether this record was submitted for
approval in the past, who were the designated approvers, and whether it was approved or
rejected.
Finally, before leaving this page, we can specify security settings to determine whether an
approver can approve or reject records from a wireless-enabled mobile device. Unless it's a
mandatory requirement for your approvers, it's better not to choose this option because it
prevents a user from manually selecting an appropriate approver for a record. We'll leave the
default choice selected for now.
216
Using Custom Workflow and Approval Processes
The last page of the New Approval Process wizard allows us to choose who should be allowed
to submit position records for approval. Again, we'll just leave the default Record Owner
selected, because there's no reason for another user to have this power.
The last two options on this page allow us to place the Approval History related list on all
Position page layouts and give users the ability to recall pending approval requests after they've
submitted them. The Approval History related list is the same history related list that we
included on the Approver page layout, so we'll also include it on the Position detail page. From
this related list users can also click the Recall Approval Request button to withdraw their
pending approval requests. If we didn't enable this last option, only administrators would have
access to the Recall Approval Request button.
18. Select Add Approval History Related List to All Position Page
Layouts.
19. Select Allow submitters to recall approval requests.
20. Click Save.
Phew! We've finished defining the framework for our approval process, but we won't be able
to activate it until we've given it some steps and some actions to fire when records are actually
approved or rejected. Let's move on to those now.
217
Chapter 8: Using Custom Workflow and Approval Processes
For our New Position approval process, we'll need to define two steps—one that requires
approval from the record submitter's manager for all new position records, and one that requires
additional approval from the CEO for position records with minimum salaries in excess of
$150,000. Let's define the first step for all new position records now.
Because we selected Yes, I'd like to create an approval step now at the end
of the Standard Approval Process wizard in the last section, we're already at the beginning of
the New Approval Step wizard. If we weren't, we could return to the same wizard with the
following steps:
In this first step, we want the approval request to go to the Position owner's manager:
The Step Number field specifies the order in which multiple steps should be processed. By
assigning this as Step 1, it will be the first to execute when the approval process is triggered.
4. Click Next.
The Specify Step Criteria area allows us to define the criteria or create a formula that filters
the records that require approval during this step. Because we've already filtered out position
records that are owned by the CEO from the whole approval process, this step does not need
any additional filtering.
5. Click Next.
Finally, we have to select the assigned approver for this step, and specify whether his or her
delegate is allowed to approve the request as well. Because this is the Manager Approval step,
it clearly makes sense to accept the default option of Automatically assign using the
custom field selected earlier. (Manager). However, because position records
aren't particularly sensitive, it's okay for managers to assign delegate approvers. So managers
who go on vacation, or who receive large quantities of approval requests, can share their work
with another employee.
218
Using Custom Workflow and Approval Processes
Having completed our first approval step, we're faced with another choice to create optional
approval or rejection actions for this step, or to return to the approval process detail page.
While we ultimately need to specify final approval and rejection actions that occur when the
approval process ends one way or the other, there's nothing in particular that needs to happen
after this first step that we can't specify elsewhere. Let's return to the detail page for our approval
process and define our second approval step for positions with minimum salaries of more than
$150,000.
Once again we're back in the New Approval Step wizard, but this time it includes a summary
of the previous step that we created. This helps us to remember where we are in our approval
process.
219
Chapter 8: Using Custom Workflow and Approval Processes
For this approval step, we only want to send positions with a minimum salary over $150,000
to the CEO. Additionally, we want to exclude any records that the CEO has already approved
(for example, because one of the CEO's direct reports created the record).
15. Select the Enter this step if the following radio button, then choose
criteria are met from the drop-down list.
16. In the first row of filters, enter Min Pay greater or equal 150000.
17. In the second row of filters, enter Current User: Manager not equal to
Cynthia Capobianco (the acting CEO in Universal Containers Role Hierarchy
on page 127).
18. Click Next.
Finally, we need to select the approver (the CEO), and specify what should happen if he or
she rejects this request.
We're keeping this approval process fairly simple, but if we wanted to, we could use the Add
Row and Remove Row links to send the approval request to multiple approvers in this step.
We could also select Related Users in the first drop-down list in the row to add an approver
who is listed in fields on the submitted record. For example, since this is an approval process
for Position records, we could add the position's hiring manager to the list of approvers.
21. Below the Add Row and Remove Row links, select Approve or reject based
on the FIRST response.
If this step was requesting approval from multiple users, the radio buttons below the Add Row
and Remove Row links would determine whether the approve request needed unanimous
approval, or if the record would be approved or rejected based on the first user to respond to
the request.
22. Select The approver's delegate may also approve this request.
220
Using Custom Workflow and Approval Processes
The next section allows us to specify what to do with the record if it's rejected at this step.
Because the position record is locked from editing during the approval process, it makes the
most sense to perform the final rejection.
23. Select Perform all rejection actions for this step AND all final
rejection actions. (Final Rejection).
24. Click Save.
Once again, we're faced with a choice to define approval or rejection actions for this particular
step. Let's circumvent those, and return to the approval process detail page to define our initial
submission, final approval, and final rejection actions for the whole process.
25. Select No, I'll do this later. Take me to the approval process
detail page to review what I've just created.
26. Click Go!
Just like workflow actions, approval actions allow you to create and assign tasks, update fields,
and send email updates and outbound messages. They can either be associated with the approval
process as a whole or with individual approval steps.
221
Chapter 8: Using Custom Workflow and Approval Processes
Because defining an approval action is almost identical to the way we created workflow actions,
we'll quickly step through the process of updating the Status field to Pending Approval when
a position is initially submitted and then leave our other approval actions as exercises:
222
Using Custom Workflow and Approval Processes
1. If you're not on the approval process detail page already, click Your Name ➤ Setup
➤ Create ➤ Workflow & Approvals ➤ Approval Processes, and then click
Approve New Position.
2. In the Initial Submission Actions related list, click Add New, and select Field Update.
Does the New Field Update Action page look familiar? That's because we've seen it before—all
approval tasks, field updates, email alerts, and outbound messages use the same editing interface
as workflow actions. In fact, every workflow and approval action that you create can be used
interchangeably on both workflow and approval processes.
Now, to finish up the rest of the approval process, define the remaining approval actions on
your own according to the values in the following table.
Final Rejection Field Update Name: Set Status to Closed - Not Approved
Actions
Field to Update: Status
223
Chapter 8: Using Custom Workflow and Approval Processes
The Approve New Position approval process automatically moves to the Active list, and a new
field is displayed: Process Order. This field is important if we're trying to use more than
one approval process at a time because it tells us the order in which each approval process will
be evaluated.
Fortunately, the Force.com platform has a Process Visualizer that renders each approval process
as a flowchart. The flowchart contains all of the critical details for each approval process,
including the steps necessary for a record to be approved, the designated approvers for each
step, the criteria used to trigger the approval process, and the actions that take place when a
record is approved, rejected, recalled, or first submitted for approval.
To access the Process Visualizer, click the View Diagram button at the top of any approval
process detail page.
224
Using Custom Workflow and Approval Processes
1. Click Your Name ➤ Setup ➤ Manage Users ➤ Users and edit the user record for
your Recruiting Manager to fill in the Manager field so the approval chain is properly
set up.
2. Log in to your app as a Recruiting Manager and create a new position.
Notice that after clicking Save, the detail page displays a Submit for Approval button in the
new Approval History related list.
225
Chapter 8: Using Custom Workflow and Approval Processes
Clicking the Submit for Approval button causes several things to happen. First, the record is
locked from editing, as shown by the lock icon at the top of the page. Additionally, two new
entries appear in the Approval History related list showing who submitted the record and the
current approval assignment. Finally, the manager of the position owner receives an email
reporting that there's a new position to approve.
226
Using Custom Workflow and Approval Processes
When the manager next logs in and visits the record, an Approve/Reject button is visible on
the Approval History related list. He or she can click this button to see the approval request
and approve or reject the record, with comments.
4. Log in as the direct manager who is responsible for approving the request.
5. Click Approve/Reject in the Approval History related list on the record, enter any
optional comments, and then click Approve.
Tip: To make accepting and rejecting approval requests more convenient, consider
adding the Items to Approve related list to the default Home page layout:
If the approver accepts the record, it progresses to the next step of the approval process (if its
Min Pay field is greater than $150,000 and the CEO still hasn't approved it), or else the
position's Status field is set to Open - Approved. The record details remain locked to protect
them from being changed, but recruiters can still associate the position with job applications,
tasks, or other activities. If the record is rejected, the Status is set to Closed - Not Approved,
the Close Date field is set to today's date, and the record is unlocked in case it just needs a
simple edit before it reenters the approval process. With just a few minutes of work, we've built
an effective business process that will make all of Universal Containers' users more effective.
Summing Up
Check out our Recruiting app now! By leveraging the platform's built-in workflow and approval
process tools, we've transformed our app from a glorified database into a fully functional
application that provides real value to its users.
Next we'll tackle something that provides real value to our executive users: reports and
dashboards that give our users a complete analytical picture of how the recruiting program at
Universal Containers is going.
228
Chapter 9
Analyzing Data with Reports and Dashboards
In this chapter ... We've come a long way with our Recruiting app—not only
do we have six custom objects to store our data, but we've
• Introducing Reports also defined security and sharing rules to protect it, and we've
• Introducing Dashboards implemented several business processes with workflow and
• Introducing Custom approvals. We've built a functional application in the cloud,
Report Types and we haven't even written a single line of code!
• Look At What We've Now it's time to turn our attention to the needs of the
Done Universal Containers managers and executive staff. Because
they need to keep track of many different aspects of the
business, we need a way to give them a bird's-eye view of
the company's recruiting activity without forcing them to
delve into piles and piles of data. To do this, we'll create a
set of custom reports for our Recruiting app and then build
a dashboard that allows users to view summaries of key
Recruiting app statistics every time they log in.
229
Chapter 9: Analyzing Data with Reports and Dashboards
Introducing Reports
We can help users monitor and analyze the data that's being generated in their organization
by building reports. Reports are summaries of the data that's stored in an app. They consist
primarily of a table of data, but can also include data filters, groupings, and a customized graph.
230
Analyzing Data with Reports and Dashboards
While a comprehensive set of reports is included with every organization to provide information
about standard objects such as contacts and accounts, we can also build custom reports that
highlight interesting metrics about the data stored in our custom objects.
231
Chapter 9: Analyzing Data with Reports and Dashboards
For example, some of the questions that an executive at Universal Containers might have about
recruiting include:
• On average, how many days does it take for each recruiter to fill a position?
• Which functional areas have the most open positions?
• Which positions have been open for more than 90 days?
• Which positions are getting the most candidates?
• Which employees conduct the most interviews?
• What does the job application pipeline look like for each open position?
• Who have we hired in the last 90 days?
We can answer all of these questions and more by creating custom reports in the Reports tab
of the app. Although this tab isn't visible by default in our Recruiting app, any user can click
the arrow tab on the right side of the tab bar to display all available tabs, and then navigate to
the reports area by clicking Reports.
Tip: If a user goes to the Reports tab on a regular basis, he or she can also add this
tab to their main tab bar by clicking the arrow tab on the right side of the tab bar,
selecting Customize My Tabs, and then moving Reports to the Selected Tabs
list. This will save them a click since they'll no longer need to click the arrow tab to
see the list of all tabs.
Report Formats
The platform supports three different report formats, each with varying degrees of functionality
and complexity:
• Tabular reports are the simplest and fastest way to look at your data. Similar to a spreadsheet,
they consist simply of an ordered set of fields in columns, with each matching record listed
in a row. While easy to set up, they can't be used to create groups of data or graphs.
Consequently, they're best used just for tasks such as generating a mailing list.
Tip: Use tabular reports when you want a simple list or a list of items with a grand
total.
• Summary reports are similar to tabular reports, except that they also allow you to group rows
of data, view summarized information (such as subtotals, averages, and so forth), and create
graphs. For example, in the sample Employee Interviewer reports that appear in the
following screenshot, the summary report groups the rows of reviews by the possible values
of the Owner Name field, allowing us to see at a glance subtotals of how many times the
two interviewers have talked to candidates and entered reviews for them.
232
Analyzing Data with Reports and Dashboards
While a little more time-consuming to set up, summary reports give us many more options
for manipulating and organizing the data, and, unlike tabular reports, they can be used in
dashboards. Summary reports are the workhorses of reporting—you'll find that most of
your reports tend to be of this format.
Tip: Use summary reports when you want subtotals based on the value of a
particular field or when you want to create a hierarchically grouped report, such as
sales organized by year and then by quarter.
• Matrix reports are the most complex kind of report available, allowing you to group records
both by row and by column. For example, in the following sample Employee Interviewer
reports, the matrix report groups the review rows by the possible values of the Owner Name
field, and also breaks out the possible values of the Position field into columns.
Consequently, the report gives us summarized information such as the number of times
an interviewer has interviewed candidates and entered reviews for a particular position.
These reports are the most time-consuming to set up, but they also provide the most detailed
view of our data. Like summary reports, matrix reports can have graphs and be used in
dashboards.
Tip: Use matrix reports when you want to see data by two different dimensions
that aren't related, such as date and product.
233
Chapter 9: Analyzing Data with Reports and Dashboards
Figure 83: Tabular, Summary, and Matrix Reports Offer Different Options for Viewing
the Same Data
You can select the Overwrite users' personal custom app customizations
option so that the Reports tab is automatically added to the tab bar by default for all users. Just
remember that this option will overwrite any changes that current users may have already made.
If you've already deployed your app and you'd rather not affect existing users, you can leave
this option unchecked, but users will have to manually add the Reports tab to their personal
tab bar by clicking the arrow tab on the right side of the tab bar, selecting Customize My
Tabs, and then moving Reports to the Selected Tabs list.
Perfect! Now let's visit the Reports tab to perform our next task: creating a folder for Recruiting
reports.
235
Chapter 9: Analyzing Data with Reports and Dashboards
Figure 84: The Reports Tab and the Folder Drop-Down List
Because every organization already comes with over fifty standard reports and around a dozen
report categories, it's important to create a new category whenever you're defining a new set
of reports. It's an easy way of making sure that your users can always find the reports they need.
To define a new report category, we simply have to define a new report folder:
1. In the Reports tab, click Create New Folder next to the Folder drop-down list.
2. In the Report Folder Label field, enter Recruiting Reports.The Folder
Unique Name field autopopulates with Recruiting_Reports. Leave this default
value.
3. In the Public Folder Access drop-down list, choose Read Only.
By choosing Read Only for this folder, only administrator users can modify the reports the
folder contains, or save new reports to it. However, because all users can create their own
reports, this won't hinder your users from modifying a report that we create and saving it to a
personal folder of their own.
236
Analyzing Data with Reports and Dashboards
Because this report is going to use so many different reporting features, we'll break down the
procedure into three parts:
1. On the Reports tab, click the Create New Custom Report button.
Before we can enter the heart of the actual wizard, we first have to choose the object or
relationship that should be the focus of the report. The primary object that we choose in this
screen specifies the records that will be counted, and the available fields that we can use to
filter, group, or display in the report.
237
Chapter 9: Analyzing Data with Reports and Dashboards
To help with navigation in this screen, all objects and relationships are grouped in categories
like Accounts & Contacts or Customer Support Reports. The custom objects and relationships
that we built for our Recruiting app are placed under the Other Reports category.
Note: The Other Reports category contains all reports that are based only on custom
objects. If you've built a custom object that's related to a standard object, such as
Account or Contact, you'll also be able to report on your custom object in the standard
object's category.
Objects that have a many-to-one relationship with another object, like Job Applications and
Positions, can either by selected on their own or in the context of their relationship with the
other object. For example, if we select Job Applications with Position, our report will count
job application records, but can filter, group, or display fields from the related position records
as well. This will come in handy a little later when we build reports that count Job Application
records. But because we need to count position records in our report and positions aren't on
the many side of a relationship, we'll stick with a standalone positions report for now.
3. Select Positions.
4. Click Next.
Now that we've chosen the Position object, we're finally able to enter the report wizard. From
this point onwards, we can jump back and forth to various wizard steps, but we can no longer
return to the original object selection screen unless we cancel out of the wizard and start over
again. While in the wizard, we can also run the report at any time to see if we have the results
we're looking for. For example, let's see what a baseline positions report looks like without any
customizations.
238
Analyzing Data with Reports and Dashboards
Note: The View drop-down list defaults to My Positions. If you are logged in as a
user who does not own any positions, select All Positions from the View drop-down
list before you click Run Report. The report will then display all the positions to which
you have access.
As you can see, without specifying any details, we already have a list of position records with
a Grand Total at the bottom. This is the equivalent of what we might see if we were creating
a tabular report without additional columns. Now let's take this basic report to the next level.
6. Click the Back button in your Web browser to return to the report wizard.
In our first wizard step, we need to choose the format of the report that we want to create.
Because we want to group rows of open positions by functional area but don't need to define
additional groupings in the columns dimension, we'll create a summary report.
The next step of the wizard allows us to specify which numerical or checkbox field values
should be included in our report, and how each of them should be summarized in our report
239
Chapter 9: Analyzing Data with Reports and Dashboards
subtotals and grand totals. We'll be talking more about what you can do on this page when
we create our second report. For now, because we're not including any numerical field values
other than record counts (which are already included in summary reports by default), we can
skip to the next wizard step.
9. Click Next.
The third step of the wizard allows us to choose up to three different fields by which to group
our rows of data. In this case, we want to group by the Functional Area field.
Once again, let's run our report to see what we've done.
240
Analyzing Data with Reports and Dashboards
We're closer now! Our report still only lists position titles, but now they're grouped by the
functional area to which they belong. Also, each grouping has a record count subtotal in
parentheses. These counts will be the basis of the pie chart that we'll add later.
13. Click the Back button in your Web browser to return to the report wizard.
Tip: When you're viewing a report, you can always click the Customize button to
get back into the report wizard. You may not always go back to the step you want, but
you can use the Jump to Step drop-down list at the top of the report wizard to
quickly go to that step.
In addition to Position Title, which is already selected by default, we also want to display
the Hiring Manager, Location, and Status fields for each record.
2. Click Next.
3. In the Report Column Order area, reorganize the order of the columns as you see
fit. This is the order of the columns as they'll display in the report from left to right,
so the field listed in the top position on this page of the wizard will be the left-most
column in the report.
4. Click Next.
241
Chapter 9: Analyzing Data with Reports and Dashboards
We're even closer to our goal. However, the Status field shows us that the report includes
some position records that have already been filled. Since we only want to view the new and
open ones, we'll need to set some filters. Conveniently, we can set these in the next step of the
wizard.
6. Click the Back button in your Web browser to return to the report wizard.
The sixth step of the wizard allows us to set the filters that should be applied to this report.
Filters define the set of records to be included in the report; for example, you can include only
records created this month or only records belong to a certain user. The Standard Filters area
lets us quickly filter by record owner and any date field, while the Advanced Filters area allows
us to filter on any field value. Because we want to view open positions across the entire
organization and not just positions that we own (by default, all custom reports include “My”
records only), we need to set two filters:
Tip: Notice that whenever you choose a checkbox field or a picklist field, like Status,
in your filter, a lookup icon ( ) becomes available next to the filter row. You can click
the lookup icon to view valid values for that field and quickly insert the ones by which
you want to filter.
Using this filter of “Status equals New Position, Pending Approval, Open - Approved” means
that our report will include only those position records with one of these three statuses. Note
that the comma between the three Status values is treated as an OR, so this one filter is the
same as using these three filters:
9. Click Next.
243
Chapter 9: Analyzing Data with Reports and Dashboards
Now let's finish up our chart and generate our final report:
244
Analyzing Data with Reports and Dashboards
Figure 90: The Final “Open Positions by Functional Area” Summary Report
Terrific! Because our report meets all of our criteria, let's save it to the Recruiting Reports
folder.
Now if we view the Recruiting Reports folder, we can see our new summary report. Next, we'll
make a matrix report that takes advantage of some of the more advanced reporting features.
Because this report is going to use so many different reporting features, we'll break down the
procedure into four parts:
Because we want to directly compare individual recruiter performance for positions that do
and do not require travel, we'll use a matrix report. That way we can group the rows of positions
by recruiter, and columns of positions by whether or not they require travel.
The Grouping step of the report wizard now allows us to group by both rows and columns.
5. Under Specify your Row Headings, select Position: Owner Name from the Subtotal
By drop-down list.
6. Under Specify your Column Headings, select Travel Required from the Subtotal
By drop-down list.
7. Click Run Report.
Our report now breaks out the possible values for the Travel Required field in the columns
dimension. Recruiters are also broken out in the row dimension, but because all custom reports
query just the report creator's data by default (that is, “My” records only), only one recruiter is
listed in the report so far. Let's keep going.
8. Click the Back button in your Web browser to return to the report wizard.
9. Click Next.
247
Chapter 9: Analyzing Data with Reports and Dashboards
For example, it doesn't make much sense to sum up the values of the Days Open column—the
resulting value would increment with every additional record that was returned and would be
a meaningless piece of data. However, if all Days Open values in a report were averaged, the
summary total would provide interesting information—the average number of days that each
position has been open.
For our report, we need to include three different types of summary information: record count,
average days open, and a custom summary field that specifies the percentage of records that
require travel. While the first two are standard summary fields that the platform supports by
default, the third will require a visit to the Custom Summary Formula editor. Let's start with
the first two:
Note: Because we don't need to include Max Pay, Min Pay, or the programming
languages checkboxes in our report, we don't need to specify how they should be
summarized. Likewise, because we're defining a custom summary formula for Travel
Required, we also don't need to specify a standard summary field for it.
248
Analyzing Data with Reports and Dashboards
The Formula Builder allows us to define a new summary formula based on the other standard
summary values that are available. In our case, we want to include a summary that shows the
percentage of position records that require travel in any given segment. To make this calculation
we need to divide two sums—the sum of records that require travel divided by the sum of all
records:
249
Chapter 9: Analyzing Data with Reports and Dashboards
We're now ready to write our formula. Similar to other formula editors in the platform, this
formula editor allows you to choose the field and summary type by easily-recognizable labels
before inserting the equivalent API values in the editor.
9. Just under the Formula section, select Travel Required from the drop-down list.
10. Select Sum from the next drop-down list.
11. Click Insert.
The formula editor now displays the following API representation of those values:
Position__c.Travel_Required__c:SUM
12. Click the Insert Operator drop-down button and choose Divide.
13. Just under the Formula section, select Record Count from the drop-down list.
14. Click Insert.
Position__c.Travel_Required__c:SUM / RowCount
We can quickly verify that the formula is correct by checking its syntax before saving.
2. Click Next.
3. In the Report Column Order area, reorganize the order of the columns as you see
fit.
4. Click Next.
250
Analyzing Data with Reports and Dashboards
For our report, we want to define three filters: one to include all positions, one to include only
those positions that were created in the last year, and one to include those with a Status of
Open - Approved or Closed - Filled.
7. In the Duration drop-down list, choose Current and Previous CY (meaning this
and last calendar year).
8. In the first row of the Advanced Filters area, define a filter for “Status equals Open
- Approved, Closed - Filled.”
9. Click Next.
A combination chart plots multiple sets of data on a single chart. Each set of data is based on a
different field, so values are easy to compare. You can also combine certain chart types to
present data in different ways in a single chart. The report we're building doesn't need a
combination chart, but they are extremely useful when comparing data, charting trends, and
so forth.
6. In the Chart Title field, enter Avg Days to Hire With and Without
Travel.
In the Conditional Highlighting section, all three of our summary fields are available to
highlight, but we just want to emphasize one: Average Days Open. That's because we want
to highlight which recruiters are closing positions in less than 30 days, less than 60 days, or
more than 60 days.
251
Chapter 9: Analyzing Data with Reports and Dashboards
7. In the first row, set the Summary Totals drop-down list to Average Days Open.
8. Set the Low Color to a shade of green by clicking on the color picker icon and
selecting a green color from the popup window.
9. In the Low Breakpoint field, enter 30.
10. In the High Breakpoint field, enter 60.
11. Set the High Color to a shade of red.
12. Click Run Report.
252
Analyzing Data with Reports and Dashboards
Figure 93: The Final “Avg Days to Hire With and Without Travel” Matrix Report
Our report succeeds in showing how well our recruiters fill positions and provides
easy-to-understand insight into why the average number of days for all positions is in the yellow
zone—in the report shown in the previous screenshot, the conditional highlighting shows that
at Universal Containers, positions that require travel are much harder to fill. Let's quickly save
this report before moving on.
14. In the Report Name field, enter Avg Days to Hire With and Without
Travel.
15. In the Report Description field, enter On average, how many days
does it take each recruiter to fill a position with or
without required travel?
16. In the Report Unique Name field, enter
Avg_Days_to_Hire_With_and_Without_Travel if that is not already the
value.
17. From the Report Folder drop-down list, select Recruiting Reports.
18. Click Save.
As we've seen, custom reports can provide a lot of interesting data that give insight into the
challenges that an organization faces. However, unless a user visits these reports on a regular
basis, much of their benefit remains untapped. How can we give users a way of keeping tabs
on the information in reports without wasting their time? The answer, as we'll see next, lies
with dashboards.
Introducing Dashboards
A dashboard is a group of different summary or matrix report charts that graphically display
custom report data. We can select up to 20 different custom reports to display in each dashboard,
and we can arrange them in two- or three-column layouts. Users can browse through all of the
dashboards that are available in the Company Dashboards folder in their organization and can
also select a favorite dashboard that always displays on the Home tab when logging in. To put
it mildly, users love the summarized views they get with dashboards, and no good Force.com
platform app is complete without at least one.
254
Analyzing Data with Reports and Dashboards
Tip: Want to click along with our dashboard instructions but don't want to spend
your time creating all these new reports? Just create the Positions Open Longer Than
90 Days report in the first row. However, if you're interested in recreating the sample
dashboard displayed here, you'll need to create the other four as well.
255
Chapter 9: Analyzing Data with Reports and Dashboards
256
Analyzing Data with Reports and Dashboards
Recruiter Status What does the job Job Applications Format: Matrix Report
application with Position
Subtotal Rows by: Position: Owner
pipeline look like
Name and then by Position: Position
for each recruiter
Title
and open position?
Subtotal Columns by: Job
Application Status
257
Chapter 9: Analyzing Data with Reports and Dashboards
1. Click the Dashboards tab and navigate to the standard list page by clicking Go to
Dashboard List near the top of the screen.
Note: Unlike other tabs, opening the Dashboards tab always displays the last dashboard
that you viewed. If you've never visited the tab before, it displays a sample dashboard
that comes by default with every organization.
258
Analyzing Data with Reports and Dashboards
The Dashboard edit page allows us to define the properties of the dashboard. Once these are
specified, we can add report components:
The Dashboard Security Settings section allow us to define the dashboard's security. Dashboards
are always executed with the security settings of a single user, the running user. Because only
one running user is specified per dashboard, everyone who can access the dashboard sees the
same data, regardless of their personal security settings.
259
Chapter 9: Analyzing Data with Reports and Dashboards
The running user's security settings only apply to the dashboard view. Once a user drills down
into a source report or detail page off the dashboard, the user will view the data based on his
or her normal security settings.
For example, suppose a system administrator with the “Modify All Data” permission is the
running user for our Recruiting Dashboard. In this case, every recruiting-related record is
counted in all of the report totals on our dashboard, including users who'd normally be restricted
from viewing certain records (like those assigned to the Standard Employee profile). Although
those users would be able to see the summary data for all records in the dashboard, if they ever
navigated to the source reports, they'd only see the records they have permission to view.
Consequently, when designing a dashboard it's important to be aware of the audience of the
dashboard and how much data they should be able to see. If you do give a user access to
dashboards that include more data than he or she normally has permission to view, be sure to
communicate that they might see different values when they click through the dashboard to
view the associated reports. And if you need to restrict a dashboard from certain users, just
save it to a restricted-access folder.
For our Recruiting Dashboard, the data that we'll be showing in the dashboard isn't particularly
sensitive. Consequently, we'll choose a system administrator as the running user, and save the
dashboard to a public folder.
7. In the Running User lookup, select a user with system administrator privileges.
8. In the Folder drop-down list, select Company Dashboards.
Other settings on this page allow you to customize the look and feel of the dashboard colors
and fonts. We'll leave these as the defaults for now.
9. Click Save.
We now have an empty dashboard that's ready to be filled with dashboard components.
260
Analyzing Data with Reports and Dashboards
• Charts—Displays a pie chart, bar chart, line chart, or any other type of chart that can be
made in a report.
• Tables—Displays a two-column table that contains record counts and values from the
top-level row grouping in the report.
• Metrics—Inserts the grand total of a report at the end of a label that you customize.
• Gauges—Uses the grand total of a report as a point on a scale.
• Visualforce Pages—Displays any Visualforce dashboard component in your organization.
We're now ready to enter specifics about how our chart should be formatted. Notice that even
though we already defined a chart for the Open Positions by Functional Area report, the
corresponding dashboard component needs to have the chart element redefined. That's because
charts that are useful in a report aren't always as useful in the smaller scale of a dashboard:
Ta-da! We now have a pie chart in our dashboard! If a user clicks on the chart, they're taken
to the report from which the chart was generated.
262
Analyzing Data with Reports and Dashboards
Now on to the appearance of our gauge. Just like the conditional highlighting in our matrix
report, this gauge can display different colors depending on the total count of positions that
have been open too long. We want a green color if there are less than two positions, yellow if
there are between two and five, and red if the value is over five.
Just like the corresponding report, we can add conditional highlighting to our table to highlight
recruiter performance levels. We want a green color if the recruiter needs less than 45 days,
yellow if he or she needs between 45 and 75 days, and red if the value is over 75.
5. From the Low Range Color color picker, choose a shade of green.
263
Chapter 9: Analyzing Data with Reports and Dashboards
Because metric components consist of a single value, they don't need a title. Instead, we give
them a label much like any other field that you see in the platform:
Note: Did you notice that we're using the same report that we used for our table?
This metric is just another interpretation of the data.
5. From the Low Range Color color picker, choose a shade of green.
6. In the Breakpoint #1 Value field, enter 45.
7. In the Breakpoint #2 Value field, enter 75.
8. From the High Range Color color picker, choose a shade of red.
9. Click Save.
10. Click Done.
264
Analyzing Data with Reports and Dashboards
We've now got a simple, four-component dashboard for our Recruiting app! If you click the
Home tab, you can add the dashboard's first row to your home page:
11. On the Home tab, click Customize Page in the upper right corner of the Dashboard
component.
12. Select Recruiting Dashboard from the Dashboard Snapshot drop-down list.
13. Click Save.
And because we saved the dashboard in a public folder, any user can add it to his or her Home
tab, too.
As you can see, once we'd created the reports for our Recruiting app, adding them to a dashboard
was a piece of cake. It's so easy, that we'll leave the remainder of the components as an exercise
for you to try on your own—see how close you can come to recreating A Sample Recruiting
Dashboard on page 229.
Refreshing Dashboards
Dashboards reflect a snapshot of your data at a specific time. On the Home tab, that time is
indicated in the upper left corner on the Dashboard component; on the Dashboard tab, it's
265
Chapter 9: Analyzing Data with Reports and Dashboards
indicated in the upper right corner. You can refresh your dashboards on either tab by clicking
the Refresh button.
If you are using Enterprise or Unlimited Edition, you can schedule dashboards to refresh
automatically at specific times, and upon completion, receive an email notification that includes
the refreshed dashboard.
Scheduling a dashboard refresh is easy. Simply click the arrow next to the Refresh button on
the Dashboards tab, and select Schedule Refresh.... Then, indicate who should receive the
notification email, and the time you want the refresh to occur.
Custom report types define the report criteria from which your users can run and create custom
reports. When you create a custom report type, you specify the objects, relationships, and fields
that users can select for their reports.
266
Analyzing Data with Reports and Dashboards
How are custom report types useful in our Recruiting app? Well, our recruiters will appreciate
it if we give them an easy way to scan for positions to which candidates have applied. In addition,
the recruiters will probably want to see which of those job applications have reviews. That way,
they'll know if any positions are on the verge of closing.
The custom report type that we're creating will include data from three different objects:
Position, Job Application, and Review. Positions will be the focus of the recruiters, though,
so let's make Position the primary object in this report type.
Next, we'll give this report type an intuitive name and categorize it so it's easy for users to find
it in the report wizard. We'll also enter a description so users who select the report type will
know its function.
5. In the Report Type Label field, enter Positions with Reviewed Job
Applications.
6. In the Report Type Name field, enter Positions_with_Reviewed_Job
Applications if it is not there already.
7. In the Description field, enter Which positions have job applications
that have been reviewed?
8. In the Store in Category drop-down list, select Other Reports.
When creating a report type, you can set its status to In Development if you want to test it
before making it available to all your users; however, the report type we're creating does not
require much testing, so set its status to Deployed.
9. Select Deployed.
10. Click Next.
The platform uses a graphical hierarchy and set diagrams (also called Venn diagrams) to let us
easily specify which related records from other objects we want to include in the report results.
11. Click the white box under box A (Positions). Box B appears.
267
Chapter 9: Analyzing Data with Reports and Dashboards
12. On box B, select Job Applications from the drop-down list, and leave Each "A"
record must have at least one related "B" record selected.
Figure 100: Report Type Hierarchy and Set Diagram for Positions and Job Applications
By leaving this option selected, we've indicated that we want this custom report type to only
include position records for which there are job applications. Notice how the set diagrams on
the right change to reflect our selection.
13. Click the white box under box B ( Job Applications). Box C appears.
14. On box C, select Reviews from the drop-down list, and leave Each "B" record
must have at least one related "C" record selected.
268
Analyzing Data with Reports and Dashboards
Figure 101: Report Type Hierarchy and Set Diagram for Positions, Job Applications,
and Reviews
We've further narrowed the scope of our report to only include job applications that have
reviews.
Our custom report type is nearly finished. In fact, we could technically say it's done now, but
there's something we can do to make it even more convenient for our users: we can reorganize
how the fields display on the Select Columns page in the report wizard for this report type.
This report type incorporates three objects (Position, Job Application, and Review), each
containing several fields. A user who is creating a report using this custom report type will
likely be overwhelmed by all of those fields, so let's remove the ones that users won't need, and
shuffle the important ones to the top. We can also specify which ones are selected by default.
16. On the Custom Report Type detail page, scroll down to the Fields Available for
Reports related list and click Edit Layout.
The page that appears is similar to the page layout editor we used in Enhancing the Simple
App with Advanced Fields, Data Validation, and Page Layouts on page 52. You can reorder
fields by dragging them, create and delete sections, and so forth. You can also double-click the
fields to change their label on the Select Columns page in the report wizard, and specify whether
they should be checked by default.
269
Chapter 9: Analyzing Data with Reports and Dashboards
Important: If a field is not in a section, it will not be available to users when they
generate reports from this report type.
17. Create a new section called Position, Job Application, and Review
Fields.
18. In the Positions section, change the label of the following fields by double-clicking
the field name and editing it in the dialog that opens:
19. In the Job Applications section, change the label of the following fields by
double-clicking the field name and editing it in the dialog that opens:
20. In the Reviews section, change the label of the following fields by double-clicking
the field name and editing it in the dialog that opens:
21. Move the following fields from the Positions section into the Position, Job
Application, and Review Fields section:
• Position Title
• Created By
• Created Date
• Days Open
• Functional Area
• Hire By
• Hiring Manager
• Open Date
• Status
• Travel Required
22. Move the following fields from the Job Applications section into the Position, Job
Application, and Review Fields section:
270
Analyzing Data with Reports and Dashboards
Notice that we didn't include the Candidate field. We left it out because this report type is
available to all users, including hiring managers. As mentioned in the previous chapter, a hiring
manager might try to poach candidates that apply for other jobs, so it's best to not reveal
candidate names in reports.
23. Move the following fields from the Reviews section into the Position, Job Application,
and Review Fields section:
• Review Number
• Created By
• Created Date
• Rating
• Days Open
• Hiring Manager
• Job Application Number
• Open Date
• Position Title
• Review Number
25. Delete the individual Positions, Job Applications, and Reviews sections.
26. Click Save.
Your custom report type is ready! To try it out, go to the Reports tab, click Create New Custom
Report, and select the Other Reports report type category. The Positions with Reviewed Job
Applications report type is in the list below.
271
Chapter 9: Analyzing Data with Reports and Dashboards
272
Chapter 10
Moving Beyond Point-and-Click App
Development
In this chapter ... Up to this point, we've built a compelling app using various
parts of the platform. We've created a data model to store
• Introducing Mash-Ups our recruiting information, put workflow and approval logic
and Web Services in place to help manage the data, and built reports and a
• Introducing Visualforce dashboard to help share the data. The fact that we were able
• Implementing the to quickly put all of these pieces together without writing
Candidate Map any code is a testament to the power of the Force.com
platform.
• Implementing the Mass
Update Status Button A tremendous amount of research and thought has gone
• Taking Your App Public into the design of the platform. Salesforce.com has strived
with Sites to anticipate the various business application needs of 21st
century companies, and has addressed many of those needs
with simple yet powerful point-and-click tools that
nontechnical users can use to achieve unique business goals.
However, it is impossible for one company to provide a
single solution that's a perfect fit for everyone. That's why
salesforce.com has made it easy for developers to write code
that builds upon the Force.com platform's point-and-click
functionality. Once you learn how to program for the
Force.com platform, you'll find that you can create apps for
the Cloud that do just about anything you can dream up.
The sky's the limit!
With the sample code and a few mouse clicks, we'll be able
to swiftly enhance our app by adding the following features:
• Candidate Map—An interactive map that shows the
locations of the candidates that have applied for a
particular position
• Mass Update Status—The ability to update the Status
field on multiple job applications at the same time
• Public Careers Site—A public Web site that anyone on
the Internet can access to see what positions are open at
Universal Containers
Let's begin!
274
Moving Beyond Point-and-Click App Development
Of course it's possible! Because the Force.com platform runs on the Web, we can leverage the
power of other websites to implement features that would never be available just through our
platform alone. This means that with a little code, we can mash up our own recruiting data
with an interactive map website, such as Yahoo! maps, and place this functionality in our own
app.
To implement a mash-up, we'll first need to understand a little about the technology that
makes it possible: Web services. A Web service is the mechanism by which two applications
that run on different platforms, that were written in different languages, and that are
geographically remote from each other, can exchange data using the Internet. Web services
makes data exchange between two such applications as straightforward as two processes
exchanging data on a single computer.
The way that data is exchanged between two Web services is similar to the way data is exchanged
between a Web browser like Microsoft Internet Explorer and a Web server. Just as a Web
browser uses a common network protocol (HTTP over TCP/IP) to download HTML files
hosted on a Web server, a Web service can also use this same network protocol to download
data from another Web service. The key difference is the actual data that is sent and
received—Web services use XML instead of HTML.
The online world has a vast array of Web services, many of which are free. For our Candidate
Map feature, we'll utilize the free Yahoo! Maps Web Services, which let you easily embed
interactive maps in your apps. If we can find a way to pass candidate addresses from our app
to the Yahoo! Maps Web Services, Yahoo! will take care of all the mapping functionality,
saving us from worrying about how our app will render an interactive map. We'll just need to
figure out how to pull that rendered map into our app.
Note: The Force.com platform also has its own powerful Web services: the Web
services API. With the Force.com Web Service API, you can customize and integrate
your Salesforce.com organization using the language and platform of your choice. The
API defines a Web service that enables full, reliable access to all of the data in your
organization, including the ability to read, create, update, and delete records.
275
Chapter 10: Moving Beyond Point-and-Click App Development
Because the Web services API is only used behind the scenes for our Candidate Map
feature, this book does not go into detail about it; however, you can find Web services
API documentation and code samples on Developer Force at developer.force.com.
Introducing Visualforce
So how do we pass our candidate's addresses to the Yahoo! Maps Web Services? And after
Yahoo! Maps Web Services renders an interactive map that plots those addresses, how do we
pull that map into our app?
These requirements may seem intimidating, but they're actually quite easy to meet, thanks to
Visualforce. Visualforce is a powerful and flexible framework for customizing your app's user
interface far beyond what's available using the platform's point-and-click tools. It's the most
efficient way to combine data from multiple Force.com objects, blend data from Web services
into your apps, or customize the logic that dictates the behavior of your app's user interface.
When you use Visualforce, you'll see your productivity increase, and you'll find that you can
create just about any type of browser-based user interface you can imagine.
The following graphic shows a few of the most commonly used Visualforce tags and how they
correspond to user interface components. Over seventy tags exist, ranging from large
components, such as a detail section of a standard page, to small components, like a single field
or link. You can learn about them all in the Visualforce Developer's Guide, at
www.salesforce.com/us/developer/docs/pages/index.htm.
276
Moving Beyond Point-and-Click App Development
The behavior of Visualforce components can either be controlled by the same logic that is used
in standard Salesforce.com pages, or you can associate your own logic written in Apex. Apex
is salesforce.com's programming language that runs in the cloud on Force.com servers.
Don't panic! You won't need to learn how to write Apex to create any of the features described
in this book. Visualforce comes with a rich component library that allows you to quickly build
pages without having to code a lot of functionality yourself. And because Visualforce markup
is ultimately rendered into HTML, you can use Visualforce tags alongside standard HTML,
JavaScript, Flash, AJAX, or any other code that executes within an HTML page. This means
that we can create our Candidate Map by simply creating a Visualforce page that uses some
basic Visualforce markup and JavaScript to pass our candidate addresses to Yahoo! Maps Web
services.
Note: To learn more about Apex, see the Force.com Apex Code Developer's
Guide, at
www.salesforce.com/us/developer/docs/apexcode/index.htm.
277
Chapter 10: Moving Beyond Point-and-Click App Development
In this book, we'll use Visualforce development mode to create and edit our Visualforce pages
because it has several features that are quite handy. One of those is the special development
footer on every Visualforce page. The footer lets you access a page markup editor that includes
tools you can use to search for values, jump to a certain line in your code, and undo and redo
changes. The page editor also offers highlighting and auto-suggest for component tags and
attributes, and has a link to the component reference documentation, which includes descriptions
and examples for every Visualforce component.
While you're in Visualforce development mode, you can create a new page just by entering a
unique URL in your browser's address bar. And as you add code to your Visualforce page,
you'll be able to save it and see your changes instantly rendered in your browser!
278
Moving Beyond Point-and-Click App Development
2. Press Enter.
The following Visualforce error page appears indicating that the page doesn't exist yet. Again,
that's okay—this gives us a chance to exercise one of the other handy features of development
mode, the quick fix. A quick fix is a way of creating something on the fly, right when we need
279
Chapter 10: Moving Beyond Point-and-Click App Development
it. In this case, even though the CandidateMap page doesn't exist yet, development mode gives
us a quick fix link to create it on the fly. Clicking the link is the equivalent of going to the
setup area, navigating to the Visualforce page section, clicking New, entering the name of the
page, and clicking Save.
Congratulations! You've created your first Visualforce page! Now it's time to add some
Visualforce markup so it displays our candidate map.
You'll notice that the page editor has the following default content:
<apex:page >
<!-- Begin Default Content REMOVE THIS -->
<h1>Congratulations</h1>
This is your new Page: CandidateMap
<!-- End Default Content REMOVE THIS -->
</apex:page>
The default content contains the Visualforce component tag <apex:page> on the first line
and the closing tag, </apex:page>, on the last line. Just like elements in other markup
languages, Visualforce component tags have a start tag, such as <apex:page>, and an end
tag that is identical to the start tag except that it has a forward slash, such as </apex:page>.
The <apex:page> tag represents a single Visualforce page. All of the other content you want
displayed on a page must be wrapped inside the start and end <apex:page> tags. As discussed
earlier, content can be other Visualforce tags, plain text, merge fields, HTML, JavaScript, and
so forth. For example, in the default content there are comments marked by the <! and >
symbols, the HTML <h1> header tag, and plain text.
Let's change the look and feel of the page so it matches the style of the Position object, the
object that's most closely tied to our candidate map. We can do this just by setting an attribute
on the <apex:page> tag. As with HTML tags, attributes on Visualforce tags configure the
style or behavior of what the tag represents.
281
Chapter 10: Moving Beyond Point-and-Click App Development
1. Place your cursor just inside the closing bracket of the <apex:page> tag, press the
spacebar, and type standardcontroller="Position__c". The result should
look like this:
<apex:page standardcontroller="Position__c">
Tip: You can develop your own controllers, but the Force.com platform
also includes a standard controller for every object, including custom objects
that you create. It's another one of the benefits of Force.com!
Note that the format for setting an attribute is the name of the attribute followed by the equals
sign (=), then the value of the attribute enclosed in quotes. Also, remember that the unique
API names of custom objects have two underscores (__) and the letter c at the end.
When you save your markup, the Force.com platform checks to make sure it's valid and lets
you know if there are errors. If the markup is valid, the new version of your Visualforce page
is saved and rendered in your browser.
Can you see how your page is different from before? Setting the standardcontroller
attribute changed the look and feel of the default Visualforce page so that the Positions tab is
selected.
282
Moving Beyond Point-and-Click App Development
Next, let's remove the default HTML on our Visualforce page and replace it with something
relevant to our Candidate Map, such as a brief description of the page just in case the purpose
of the map isn't immediately obvious to users.
4. Enter the following markup between the start and end <apex:page> tags.
This map shows the locations of candidates who have applied
for the <b>{!Position__c.Name}</b> position.
The description includes the {!Position__c.Name} merge field enclosed in the <b> HTML
tag. We've used merge fields quite a bit while building our app. They were in our email template
and some of our formulas. Now, we're using them once again, this time side by side with
HTML and Visualforce component tags.
Right now, our merge field isn't displaying because the Candidate Map is out of context, that
is, there's no specific position record from which it can grab the data. Don't worry about that
for now—we'll learn how to set context later. For now just trust that the
{!Position__c.Name} merge field will render the position name, and the <b> HTML tag
will make it bold.
Our Visualforce page is now ready for us to add our interactive map!
Important: Make sure that Word Wrap or any feature that might add line
breaks to the code is turned off in your text editor. You must preserve the
original line breaks in the code sample. New line breaks caused by word
wrapping features in text editors can break the code and prevent the code
sample from working correctly.
Also, be aware that copying code from Adobe PDF files can also cause
code to break, so avoid copying code from PDF versions of this book.
2. Select the entire content of the file, and copy and paste it into the page editor at the
bottom of your CandidateMap Visualforce page. The CandidateMapSample file
contains the Visualforce markup you added in the steps above, so just replace
everything in the page editor with the entire sample in the file.
3. Click the save icon ( ) on the page editor.
The interactive map should appear on your CandidateMap Visualforce page, but with an error
message and without plots. This is because the Candidate Map is still out of context and the
page can't figure out which candidates to show. We can fix this by simply adding the
CandidateMap Visualforce page to our position page layouts.
We have two page layouts for the Position object and we'll want the map to appear on both.
Let's start by adding the page to the original position page layout (Position Layout).
If you have any standard position records that use the Position Layout, navigate to one of those
positions and click the Edit Page Layout link in the upper right corner of the record. If you
don't have any standard position records:
284
Moving Beyond Point-and-Click App Development
The Position Layout is ready to edit. Let's create a section on the page layout for the
CandidateMap Visualforce page.
Now let's move the CandidateMap Visualforce page into our new section.
Notice that the palette lists our CandidateMap Visualforce page as a user interface element.
11. Drag the CandidateMap user interface element from the palette to the Candidate
Map section on the page layout.
The Candidate Map JavaScript generates a map that is 400 pixels high and spans the width
of the screen. This is just large enough to be useful without consuming too much room on the
screen. The default properties of the Visualforce page user interface element need to be adjusted
to accommodate the map. Otherwise, there might be odd spacing around the map and
distracting scrollbars.
Let's fix the Visualforce page user interface element properties to accommodate the size of the
generated map, as well as the text we added to the top of the CandidateMap Visualforce page.
(In case you don't remember, the text is “This map shows the locations of candidates who have
applied for the <b>{!Position__c.Name}</b> position.”)
The height is always in pixels, while the width can be specified either in pixels or as a percentage.
Setting the height to 405 pixels allows 400 pixels for the map and five more pixels for the text.
Perfect!
15. Leave the Show scrollbars and Show label checkboxes deselected.
16. Click OK to exit the user element properties.
17. Click Save on the page layout.
285
Chapter 10: Moving Beyond Point-and-Click App Development
Repeat all of the above steps for your other Position object page layout, the IT Position Layout.
Once you finish, it's time to test the Candidate Map!
Notice how the Candidate Map Visualforce page is embedded within our Recruiting app just
like the other functionality we built using the platform's point-and-click tools. Also notice
that the map automatically displays only candidates who applied to this position.
With very little programming and a few clicks, we've mashed up Yahoo Maps Web Services
with Force.com and made the result look as if it were made expressly for our Recruiting app.
Couple the Force.com Web Services API with the thousands of Web services that are available
on the Internet today, and the possibilities are limited only by our imaginations!
286
Moving Beyond Point-and-Click App Development
Fortunately, creating tools that perform mass actions on data is yet another of the innumerable
ways you can build upon the platform's functionality. With a few lines of Visualforce and the
platform's point-and-click tools, we can enhance the Recruiting app in a way that will
dramatically increase our users' productivity. When we're done, the daunting task of updating
the Status field on multiple job applications will be reduced from hours of tedium to a few
seconds of easy mouse clicking.
When designing a new feature, it's important to consider the context in which users will access
it. Since the purpose of the Mass Update Status feature is to update the Status field on
multiple job applications for a single position, it's most likely that users will want to perform
this operation while viewing a position record. Therefore, it makes the most sense to provide
access to the Mass Update Status feature from position records.
So where exactly on a position record should we provide access to the feature? Well, back in
Expanding the Simple App Using Relationships on page 83, we added a Job Applications
related list to our position records that made it easy for users to quickly identify all of the job
applications submitted for a position. We could leverage that list by adding a checkbox next
to each job application so that users can select the group of job applications they want to update.
287
Chapter 10: Moving Beyond Point-and-Click App Development
Then we could add an Update Status custom list button that lets users update the Status
fields on all of the selected job applications in one fell swoop.
Once we're done, the feature will work something like this:
1. Open a position record and scroll down to the Job Applications related list.
2. In the Job Applications related list, select the checkboxes next to the job applications
you want to update.
It may sound like this will take an astounding effort to implement, but it's really quite simple.
All you need to do is create the Mass Update Status page with some basic Visualforce markup,
and add a custom list button to the Job Applications related list on position records. You'll be
done before you know it!
288
Moving Beyond Point-and-Click App Development
2. Press Enter.
3. Click the Create Page MassUpdateStatus link.
We now have a new Visualforce page called MassUpdateStatus. Next, we'll add the Visualforce
markup that implements the Mass Update Status functionality.
To enter our markup, we'll use the Visualforce development mode page editor just as we did
before. But this time around, we won't need any JavaScript; Visualforce will be able to do it
all!
4. In the footer at the bottom of the MassUpdateStatus Visualforce page, click Page
Editor to display the Visualforce development mode page editor.
5. Delete all of the default markup in the Visualforce development mode page editor
and replace it with the following markup. Remember that instead of typing, it's
easiest to copy and paste the code from the MassUpdateStatusSample file located
in the RecruitingApp-4_0.zip file you downloaded from
http://developer.force.com/books/fundamentals.
<apex:page standardController="Job_Application__c"
recordSetVar="applications">
<apex:sectionHeader title="Mass Update the Status of Job
Applications"/>
<apex:form >
<apex:pageBlock >
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save"
action="{!save}"/>
<apex:commandButton value="Cancel"
action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Status Update"
collapsible="false">
<apex:inputField
289
Chapter 10: Moving Beyond Point-and-Click App Development
value="{!Job_Application__c.Status__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Selected Job
Applications" columns="1">
<apex:pageBlockTable value="{!selected}"
var="application">
<apex:column value="{!application.name}"/>
<apex:column
value="{!application.position__r.name}"/>
<apex:column headerValue="Candidate Name">
<apex:outputText
value="{!application.candidate__r.First_Name__c & ' '
&
application.candidate__r.Last_Name__c}"/>
</apex:column>
<apex:column
value="{!application.Status__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Tip: In this sample code, notice that some components don't have close
tags. If there are no other components nested within a component, you can
“close” the tag by putting a forward slash at the end of the start tag, like this:
<apex:sectionHeader/>.
6. Click Save.
Tip: To see general descriptions and examples for all of the Visualforce components
and their attributes, click the Component Reference link in the upper right corner
of the Visualforce development mode page editor.
<apex:page>
As with all Visualforce pages, the MassUpdateStatus page must begin with an <apex:page>
component. Notice the tag has the same standardController attribute used in our
interactive Candidate Map feature, although this time it is set to the Job Application object
290
Moving Beyond Point-and-Click App Development
(Job_Application__c). This makes sense because the Mass Update Status feature updates
a field on job application records, not position records.
The component also has a recordSetVar attribute. We use this attribute to change the
standardcontroller so that it accommodates a set of records rather than a single record.
<apex:sectionHeader>
The <apex:sectionHeader> component adds a header to the top of the page. The
component's title attribute determines the text in the header.
<apex:form>
The <apex:form> component establishes a section on the page in which users can enter data
and submit it by clicking a button or link. It's like an invisible container, similar to a <form>
element in HTML.
<apex:pageBlock>
The <apex:pageBlock> component designates an outlined area on the page similar to the
areas on detail pages that contain sections.
<apex:pageMessages>
The <apex:pageMessages> component allocates space for standard system messages (such
as those that notify users when a file is being saved) and validation rule errors. These messages
already exist in the Force.com platform, so you don't have to create them—you just have to
use this component to make room for them in case the platform needs to display them.
<apex:pageBlockButtons>
The <apex:pageBlockButtons> component allocates space for a set of buttons on the
page. Its subcomponents specify what the buttons do and how they are labeled.
<apex:commandButton>
Each <apex:commandButton> component creates an individual button inside the
<apex:pageBlockButtons> component. The Mass Update Status page uses two
<apex:commandButton> components: one to create a Save button and a second to create
a Cancel button. The buttons are styled like standard Salesforce.com buttons.
291
Chapter 10: Moving Beyond Point-and-Click App Development
Each button appears twice on our MassUpdateStatus page—once at the top of the area allocated
by the <apex:pageBlock> component and once at the bottom. This is a precautionary
measure built into the <apex:pageBlockButtons> component to ensure that the button
functionality is apparent to users, even if the page block is large.
<apex:pageBlockSection>
The <apex:pageBlockSection> component can be used within <apex:pageBlock>
components to create a section on a page similar to the sections found on page layouts. On
this page, the <apex:pageBlockSection> component is used twice.
<apex:inputField>
The <apex:inputField> component renders the Status field from the Job Application
object on our page. Use <apex:inputField> components to create HTML input elements
for any Salesforce.com field. All you need to do is set the component's value attribute to the
API name of the Salesforce.com object and field.
<apex:pageBlockTable>
The <apex:pageBlockTable> component renders a table containing field values from
multiple records of a specific object. For our feature, we need to set two of this component's
attributes: value and var.
The value attribute tells the table which set of records contains the values to display. In this
instance, we set the attribute to the expression {!selected} to enable the table to display
values from the selected job applications.
The second attribute, var, creates a name that components within the table can use to reference
individual records in the record set without actually referring to each record by name.
292
Moving Beyond Point-and-Click App Development
<apex:column>
The <apex:column> components inside the <apex:pageBlockTable> determine the
columns of the table and the job application fields each column displays. For three of the four
<apex:column> components, we just need to set the value attribute to an expression that
references the field using the value of the <apex:pageBlockTable> component's var
attribute followed by the API name of the field. For example, the following expression displays
the values of the Job Application Number field:
{!application.name}
For the Candidate Name field, though, we need to do a bit more because the field is actually
a combination of the First Name and Last Name fields from the Candidate object. To
combine these fields, we use an <apex:outputText> component inside an <apex:column>
component and set its value attribute to an expression that combines the First Name and
Last Name fields from the Candidate object.
<apex:column headerValue="Candidate Name">
<apex:outputText value="{!application.candidate__r.First_Name__c
& ' '
& application.candidate__r.Last_Name__c}"/>
</apex:column>
When you generate column fields in this manner, the value attribute on the <apex:column>
component is not set, so the table doesn't know what to use as the column header. Rectify this
by setting the headerValue attribute on this <apex:column> component.
293
Chapter 10: Moving Beyond Point-and-Click App Development
You might be wondering why we chose the Job Application object instead of the Position
object, given that the button will appear on position records. The reason is that you create list
buttons on the object that is being listed.
The custom button edit page should look familiar, since it closely resembles the formula editor
that we saw previously.
We now have the option to specify whether we are creating a detail page link, detail page
button, or list button. We've already decided to create a list button, but keep these other options
in mind for future apps.
When we selected the List Button option, did you notice the Display Checkboxes
(for Multi-Record Selection) checkbox that appeared beneath it? By leaving this
option selected, the platform knows to put checkboxes next to the records in the related list.
Next, the Behavior picklist lets you choose what happens when a user clicks the button. We
know we want the button to open the Mass Update Status page, but we can specify whether
the page opens in a new window or in the existing window, and whether or not it is has a
sidebar and header. You can even configure the button to execute some JavaScript if necessary.
294
Moving Beyond Point-and-Click App Development
For our app, it makes the most sense to configure the button to open the Mass Update Page
in the existing window, and to leave the sidebar and header there as well.
Now we need to specify the content we want to display. To do this, we'll first need to indicate
the type of content we want to display in the Content Source picklist.
When you select the Visualforce Page option, the bottom section of the custom list
button edit page displays a Content picklist. The picklist contains the Visualforce pages in
your organization that have a standard controller set to the object for which you are creating
the button.
After clicking Save, you are reminded that no users will be able to access the button until it is
added to a page layout. This is because creating a custom button is similar to adding a custom
field to an object—even if it's defined in the database, nobody will be able to see it until you
explicitly add it to a page layout.
295
Chapter 10: Moving Beyond Point-and-Click App Development
Here we can specify the standard and custom buttons that the related list displays. The Update
Status button we just created should appear in the Available Buttons list.
6. Select the Update Status button and click Add to move it to the Selected Buttons
list.
7. Click OK to exit the Related List properties window.
8. Click Save.
Repeat the above procedure for the other Position page layout. Once that's done, the Mass
Update Status feature is ready to test!
Now select a few job applications and click the Mass Update button. Our Mass Update Status
Visualforce page appears. Notice that the lower half of the page list the job application we
selected on the previous page.
296
Moving Beyond Point-and-Click App Development
In the Status picklist, choose the new status for the selected records, and click Save.
Salesforce.com updates all of the selected records with the new value.
While most of the data in our Recruiting app is highly sensitive and should only be accessible
to users with the appropriate permissions, there is one piece of data that should definitely be
publicized: open positions. By enabling job seekers outside of the company to view the positions
that are available, we expand the pool of candidates and increase the odds of hiring the best
person available. This is central to the success of not only the Human Resources department
at Universal Containers, but the entire company.
In the past, to make Force.com data available to the general public, you had to set up a Web
server, create custom Web pages ( JSP, PHP, or other), and use the API to integrate Force.com
apps with an external website. This is no longer the case, thanks to Sites!
297
Chapter 10: Moving Beyond Point-and-Click App Development
Introducing Sites
With Sites, you can create public websites that are directly integrated with your Force.com
organization. Anyone on the Internet can access these sites without logging in with a username
and password.
Use sites to selectively expose a subset of your Force.com data through pages that are branded
to match the look and feel of your company's website. For example:
• Host a public community forum for sharing and voting on ideas about your company,
services, or products.
• Provide support information on a public website where customers can search for solutions
to their issues.
• Add a public tool to your portal that helps customers find stores in their area.
• List all of your company's products on a public website, with model numbers, current prices,
and product images pulled dynamically from your organization.
Sites are hosted by salesforce.com on the same servers that host the Force.com Web domain,
so there are no data integration issues. And because you build sites on the Force.com platform
with Visualforce pages, the Force.com platform handles all of the validation on the data collected
through the site.
You can build multiple Force.com sites for your organization. For example, you can create one
site for your Marketing department, a separate one for a community forum, and another for
an online catalog.
In this chapter, we're going to build a very basic site called Career Resources that will allow
any Web user to view the open positions at Universal Containers. While it's possible to add
just about any kind of functionality to this site, such as search options and electronic job
application forms, we're going to keep it simple to limit the amount of Visualforce needed to
get the job done. By the time you're done with this chapter, though, anyone on the Internet
will be able to see the positions that are open at Universal Containers, and you'll have a solid
understanding of the power of Sites. Let's begin!
298
Moving Beyond Point-and-Click App Development
Before you begin creating sites, you must register a unique Force.com domain name that will
identify your account's space on the Force.com domain. Your Force.com domain name is a
URL that consists of a prefix followed by a string of characters that Salesforce.com provides.
Prior to creating your first site, you must register your Force.com domain name. You only have
to do this one time, though. Once your Force.com domain name is registered, you never have
to repeat this part of the process again.
The sites registration page appears. Near the bottom of the page is a text box in a URL. This
is where you will enter the prefix for your Force.com domain name. Before you do, though,
consider the following:
• The Force.com domain name can contain only underscores and alphanumeric characters
(no spaces or punctuation), and must begin with a letter. Also, it can't end with an
underscore or contain two consecutive underscores.
• Your Force.com domain name must be unique throughout the entire Force.com domain.
To avoid any duplicate entries, consider using your company's name or a variation of your
company's name, such as mycompanysite.
• Salesforce.com combines the prefix you enter with the rest of the URL on the page to
create your Force.com domain name. For example, if you enter mycompanysite as your
prefix and the rest of the URL is -developer-edition.na1.force.com, your full
Force.com domain name will be
http://www.mycompanysite-developer-edition.na1.force.com.
299
Chapter 10: Moving Beyond Point-and-Click App Development
2. In the text box, enter a prefix for your Force.com domain name.
3. Click Check Availability.
Salesforce.com quickly scans all of the other Force.com domain names to make sure the one
you entered is unique. If your Force.com domain name is unique, you'll see a message indicating
it's available. If it's not unique, you'll have to try another name.
4. Click the link to review the Sites Terms of Use. Acknowledge your acceptance by
selecting the checkbox.
5. Click Register my Force.com Domain.
A prompt appears warning that you can't change your Force.com domain name after you
register it.
6. Click Ok.
300
Moving Beyond Point-and-Click App Development
1. Click New.
The Sites edit page appears. The first field, Site Label, is the name of the site as it appears
in the administration setup area of the Force.com platform user interface.
When you click out of the Site Label text box, notice that the value Career_Resources
appears in the Site Name text box. Site Name is the name used when referencing the site
in the API.
Every site must have a designated user who can receive site-related communications from the
site's visitors and salesforce.com.
5. In the Site Contact field, click the lookup icon and choose yourself if your name
is not already the default value.
The next field, Default Web Address, displays your Force.com domain name followed by
a text box. In the text box, enter a unique domain suffix using alphanumeric characters. The
Force.com domain name and suffix constitute the complete default Web address for this site.
For example, if your Force.com domain name is
http://www.mycompanysite-developer-edition.na1.force.com and the suffix
is careers, the default Web address for this site is
http://www.mycompanysite-developer-edition.na1.force.com/careers.
After we set up and activate the site, anyone on the Web will be able to access the site by
entering the default Web address.
As with any Web page, you can allow your site to be accessed via an alternative URL, one that
is perhaps shorter or easier to remember. To do this, you have to set up a custom Web address
through a domain name registrar and configure it to redirect users to the default Web address
301
Chapter 10: Moving Beyond Point-and-Click App Development
specified above. If you are building the Recruiting app in your sandbox or a version of
Salesforce.com other than Developer Edition, you'll see a Custom Web Address field in
which you can enter that custom Web address. For now, leave this field blank; however, if you
create a custom Web address in the future for this site, return to this page to enter the address
in this field.
7. Leave the Custom Web Address text box blank.
A site is not available to the public until it is activated. If you were creating a site for a public
company or working on a complex site that took several days to develop, it would make sense
to create and test the site before making it available to everyone. Since we're creating a simple
site for a fictitious company, it's OK for our site to be immediately available when we save this
page.
The Active Site Home Page field lets you specify which Visualforce page people see if
they navigate to your site when it's active. Ultimately, we'll want this to be a Visualforce page
that displays all of the open positions at Universal Containers page, but we haven't created
that page yet. For now, let's just use the default UnderConstruction page included with the
Force.com platform.
Even though we opted to make our site immediately active, there still may be times in the
future in which we'll want to deactivate the site for maintenance or redesigning. When the site
is inactive, users are redirected to the Visualforce page listed in the Inactive Site Home
Page field. Again, the Force.com platform includes a default Visualforce page for this purpose.
10. In the Inactive Site Home Page field, leave InMaintenance selected.
We haven't begun designing the pages of our site yet, but while we're setting up our site's basic
configuration, we can specify a site template to make the construction of our site's pages much
easier. A site template is a Visualforce page that lets you dictate the style and layout of any of
your site's pages that don't reference a specific site template. That is, every page on your site
will inherit the site template's look and feel unless you specify another template on the page
itself. With site templates, you can control the visual styling of your entire site from a single
file!
If you have multiple sites, you can use the same site template for each site to preserve a uniform
style throughout your company's entire Web presence. Alternatively, you can create different
site templates for different sites so that visitors instantly recognize a change in context. For
our Careers Resources site, we're going to use the default Visualforce page provided with all
organizations called SiteTemplate.
302
Moving Beyond Point-and-Click App Development
The next three fields and checkbox are a bit technical and don't affect our site's functionality,
so we're going to leave them blank. It's useful to understand what they can do, however, since
it's quite likely you'll want to utilize them when creating sites in the future:
Site Robots.txt
This file determines which parts of your public site are accessible to Web
crawlers. A Web crawler is a computer program that browses the Web and
retrieves current data. The data is primarily used by search engines for
indexing purposes, and for automating maintenance tasks on Web sites,
such as checking for broken links. However, there are reasons to deny
Web crawlers access to your site. For example, some Web crawlers are
maliciously designed to gather contact information from Web pages, such
as email addresses, for spam. Also, Web crawlers can consume networking
resources, impeding download rates for legitimate Web users.
Site Favorite Icon
This icon appears in a browser's address field when a user visits the site.
You can use this field to set the favorite icon for your entire site, or you
can specify an icon for each individual page.
Analytics Tracking Code
This code lets you easily integrate your site with Google Analytics. By
integrating your site with Google Analytics, you can track the usage of
your site and site pages, including the number of visits and page views
over a specific period of time, the average time visitors spent on the site,
and more.
Enable Feeds
This option displays the Syndication Feeds related list, where you can
create and manage syndication feeds for users on your public sites.
Syndication feeds give users the ability to receive updates in external news
readers when there are changes to a site. This field is visible only if you
have the feature enabled for your organization.
303
Chapter 10: Moving Beyond Point-and-Click App Development
Your first site is live! If you go to the URL you entered in the Default Web Address field
or just click the link in the Default Web Address field on the Site detail page, you'll see
the UnderConstruction Visualforce page that we selected as our Active Site Home Page.
Note: Sometimes it takes a few minutes for changes to your sites to appear. If the
changes don't appear immediately, check back a few minutes later.
Notice that the email us link opens an email addressed to the site contact.
If you go back to the Site detail page and scroll down, you'll see several related lists that display
information such as the site's usage and change history. One of these related lists contains the
various Visualforce pages associated with the site. These are default pages included with the
304
Moving Beyond Point-and-Click App Development
platform though, and none of them display the positions open at Universal Containers, which
is the whole reason we're building the site. We'll have to create that page ourselves, but that
won't be hard since we already picked up a few Visualforce tricks earlier in this chapter.
First, we know that we want the page to display some of the data on position records, such as
each position's title, location, and description. Those are essential bits of information to job
seekers. We probably shouldn't make the pay ranges public, though, since that information
could give candidates the upper hand when negotiating salaries. Also, keep in mind that the
page is going to list all open positions, and large scale companies might have hundreds or
thousands of open positions. For that reason we'll want to restrict the information we display
to just the three essential fields mentioned above.
Next, we have to decide how the page will look. What colors will we use? What format will
we use to render the data? As mentioned before, we want to keep things simple, so let's give
the page the same look and feel that position records have in our app. We'll render the data
in a table, and we'll add a brief introductory blurb above the table that will orientate the site's
visitors by describing the contents of the page and how they should use it. Let's begin!
2. Press Enter.
3. Click the Create Page PublicJobs link.
We now have a new Visualforce page called PublicJobs. The next step is to add the Visualforce
code to the page that will display open positions.
4. In the footer at the bottom of the PublicJobs Visualforce page, click Page Editor to
display the Visualforce development mode page editor.
5. Delete the default markup in the Visualforce development mode page editor and
enter the following:
305
Chapter 10: Moving Beyond Point-and-Click App Development
Tip: You can cut and paste this markup from a file in the
RecruitingApp-4_0.zip file you downloaded from
http://developer.force.com/books/fundamentals.
<apex:page standardController="Position__c"
recordSetVar="positions" sidebar="false" showHeader="false">
<apex:pageBlock>
<h1>Welcome to the Universal Containers Careers Home
Page!</h1>
<p>Universal Containers is an industry leader, but to stay
ahead of the pack, we need to grow!
We are currently seeking bright and talented
professionals to join our winning team. Browse
the current openings below and email your resume to
apply.
</p>
<br/>
<apex:pageBlockTable value="{!positions}" var="position">
<apex:column value="{!position.name}"
rendered="{!IF(position.Status__c == 'Open
- Approved', true, false)}"/>
<apex:column value="{!position.Location__c}"
rendered="{!IF(position.Status__c == 'Open
- Approved', true, false)}"/>
<apex:column value="{!position.Job_Description__c}"
rendered="{!IF(position.Status__c == 'Open
- Approved', true, false)}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
6. Click Save.
306
Moving Beyond Point-and-Click App Development
You probably recognize the components in the markup since we used all of them before in our
Mass Update Status feature. The page begins with the familiar <apex:page> and
<apex:pageBlock> components, followed by a few elementary HTML tags that add a
header and some introductory text. Then the <apex:pageBlockTable> component and a
few <apex:column> components create a table that displays fields from a set of records.
Simple!
While all of the components are familiar, the markup uses a few attributes that we haven't seen
yet. Let's take a look at them.
First, in the <apex:page> component, we set the sidebar and showHeader attributes to
false. These attributes specify whether the page displays the standard sidebar and tab header
you see on your app's pages. If we set these values to true or don't set them at all, the sidebar
and header are visible. However, the search functionality in our app is restricted to registered
users, so having the sidebar appear might mislead our site's visitors into believing they can
search for positions when in fact their search attempt will result in an error message. As for
the tabs, they don't really make sense on a single-page site like the one we're building, so we
shouldn't display them. Therefore, both of these attributes are set to false.
307
Chapter 10: Moving Beyond Point-and-Click App Development
The other attribute that we haven't covered yet is the rendered attribute on the
<apex:column> component. If the value of this attribute is true, the field specified in the
value attribute appears in the table; if the value is false, the field doesn't appear. Since this
value shouId change depending on the status of the position we're displaying, we've set the
attribute to an expression that resolves to either true or false. That way, the page can dynamically
determine whether or not to display fields.
For example, the rendered attributes in our markup are set to the following expression:
{!IF(position.Status__c == 'Open - Approved', true, false)}
The expression uses a simple IF() function that only resolves to true if the Status field on
a position record is set to “Open — Approved.” This means that our <apex:column>
components will only display fields from position records that are open, which is perfect because
we only want open positions to appear on our Public Jobs page.
That's all the Visualforce markup we'll need for our site! We just have a few more clicks left
to finish up our app.
The Public Jobs page is now the home page for your Career Resources site; however, if you
launch the default Web address in your browser, the Public Jobs page is not there. Instead,
you see a Web page with a message saying that authorization is required. Why would
authorization be necessary to access a public site?
It turns out there's still one step left. We have to grant public access to the position object.
we're setting them specifically for this site and not the entire app. In fact, the settings only
apply to Internet users who do not have a Recruiting App login.
For our site, we need to give the public “Read” access to the Position object. If we don't, the
platform will not render the Public Jobs page because the page contains position data to which
the public doesn't have access.
Testing your site is easy—simply point your browser to the site's default Web address. You
can do this by entering the default Web address in your browser's address bar, or by clicking
the Default Web Address link on your site's detail page.
Once the Public Jobs page loads, you can see the title, location, and description of each open
position at Universal Containers, even if you aren't logged in to the Recruiting App. We've
successfully published a subset of our data while keeping the rest of it secure!
We're going to stop here since we achieved our targeted goal of creating a public site. However,
it's good to think about the additional functionality that you could build into your site to
improve its usability. For instance, career websites like ours typically have search capabilities
that let visitors view positions based on specified criteria. Also, it's nice to give users a more
efficient way to apply online rather than sending a resume in an email.
All this and so much more can be implemented using advanced Visualforce markup and Apex.
Those topics are out this book's scope, but they are thoroughly covered in the various resources
available at developer.force.com. If you go on to learn more about Visualforce and Apex, you
can become a true master of cloud computing!
309
Chapter 11: Learning More
Chapter 11
Learning More
In this chapter ... This book has introduced some of the native technologies
associated with the Force.com platform. We've created a
• Developer Force fully functional Recruiting app, and we've introduced
• Help and Training Visualforce and the Web services API to show you how it
Options can be used to build composite apps. But there's only so
• Podcasts much we can cover in a single book—we skipped over many
• AppExchange Partner other powerful tools and options, and didn't talk about how
you can share your own apps with others on the
Program
AppExchange. Indeed, we'd be surprised if you didn't have
• What Do You Think? more questions about how you can take advantage of all that
the platform has to offer!
310
Learning More
Developer Force
The Developer Force website is the place to be for Force.com developers. It provides a full
range of resources including sample code, toolkits, an online developer community, and the
test environments necessary for building apps. It includes an online version of this book (written
by Developer Force staff members) and has information about the Dreamforce event that we
hold every year for Force.com platform developers. If you need more info, have a question to
ask, are seeking a toolkit or sample, or just want to dig a little deeper into Force.com platform
development, the Developer Force website is the first place you should go.
• Get the next volume in the Force.com platform book series—the Force.com Cookbook.
This book contains dozens of “recipes” for both novice and expert developers. Learn how
you can add even more exciting functionality to your apps by accessing the Force.com
platform API, developing Apex scripts, and creating Visualforce pages.
• Download the Force.com Platform Developer Guide and become an expert in building apps
for the cloud.
311
Chapter 11: Learning More
This book moves beyond the native functionality of the platform to give you an in-depth
look at developing with the Force.com platform. Learn how to use Visualforce, Apex, the
Eclipse-based Force.com IDE, and Sites to build complete apps that are secure and powerful.
312
Learning More
Select the Training tab of the Help & Training window, choose your role and geographic
location, and click View Classes! to find free online training classes. More than fifteen
online training classes are available to you on-demand, 24/7!
• Attend a Class
A number of examples in this book have been provided by Salesforce.com Training &
Certification and are drawn from the expert-led training courses available around the world.
Salesforce.com training courses provide an opportunity to get hands-on experience with
the Force.com platform and Salesforce.com applications, and prepare you to become
Salesforce.com Certified. To learn more or register for a class, visit
www.salesforce.com/training.
Podcasts
Thanks to the hard work of our colleagues on the Salesforce.com Community website, we
have an impressive number of podcasts available on our iTunes channel. You can access our
iTunes area by searching for “salesforce” on the iTunes Music Store.
This public podcast channel keeps the Force.com platform community connected by providing
free access to a wide range of best practices, case studies, and product- and platform-focused
digital audio content via the iTunes Music Store. Access to expert Force.com platform and
CRM content is a quick download away. Now you can hear salesforce.com podcasts—covering
everything from luminary interviews and thought-leadership presentations to roundtable
discussions and best practices—whenever, wherever you like. Choose from over 70 podcasts.
Happy listening!
313
Chapter 11: Learning More
both new and established businesses to join this growing community of cloud computing
providers.Visit the Partner Program website at www.salesforce.com/partners/ and join the
Force.com AppExchange partner program today!
314
Glossary
A
Activity (Calendar Events/Tasks)
Planned task or event, optionally related to another type of record such
as an account, contact, lead, opportunity, or case.
Administrator (System Administrator)
One or more individuals in your organization who can configure and
customize the application. Users assigned to the System Administrator
profile have administrator privileges.
Advanced Function
A formula function designed for use in custom buttons, links, and
s-controls. For example, the INCLUDE advanced function returns the
content from an s-control snippet.
Analytic Snapshot
An analytic snapshot lets you report on historical data. Authorized users
can save tabular or summary report results to fields on a custom object,
then map those fields to corresponding fields on a target object. They can
then schedule when to run the report to load the custom object's fields
with the report's data.
Analytic Snapshot Running User
The user whose security settings determine the source report's level of
access to data. This bypasses all security settings, giving all users who can
view the results of the source report in the target object access to data they
might not be able to see otherwise.
Analytic Snapshot Source Report
The custom report scheduled to run and load data as records into a custom
object.
Analytic Snapshot Target Object
The custom object that receives the results of the source report as records.
Apex
Force.com Apex code is a strongly-typed, object-oriented programming
language that allows developers to execute flow and transaction control
statements on the Force.com platform server in conjunction with calls to
the Force.com API. Using syntax that looks like Java and acts like database
stored procedures, Apex code enables developers to add business logic to
315
Chapter 13: Glossary
most system events, including button clicks, related record updates, and
Visualforce pages. Apex scripts can be initiated by Web service requests
and from triggers on objects.
Apex Controller
See Controller, Visualforce.
Apex Page
See Visualforce Page.
App
Short for “application.” A collection of components such as tabs, reports,
dashboards, and Visualforce pages that address a specific business need.
Salesforce.com provides standard apps such as Sales and Call Center. You
can customize the standard apps to match the way you work. In addition,
you can package an app and upload it to AppExchange along with related
components such as custom fields, custom tabs, and custom objects. Then,
you can make the app available to other Salesforce.com users from
AppExchange.
App Menu
See Force.com App Menu.
AppExchange
AppExchange is a sharing interface from salesforce.com that allows you
to browse and share apps and services for the Force.com platform.
Application Programming Interface (API)
The interface that a computer system, library, or application provides in
order to allow other computer programs to request services from it and
exchange data between them.
Approval Action
See Workflow and Approval Actions.
Approval Process
An approval process is an automated process your organization can use to
approve records in Salesforce.com. An approval process specifies the steps
necessary for a record to be approved and who must approve it at each
step. A step can apply to all records included in the process, or just records
that have certain attributes. An approval process also specifies the actions
to take when a record is approved, rejected, recalled, or first submitted for
approval.
Auto Number
A custom field type that automatically adds a unique sequential number
to each record. These fields are read only.
316
Glossary
B
Boolean Operators
You can use Boolean operators in report filters to specify the logical
relationship between two values. For example, the AND operator between
two values yields search results that include both values. Likewise, the OR
operator between two values yields search results that include either value.
C
Class, Apex
A template or blueprint from which Apex objects are created. Classes
consist of other classes, user-defined methods, variables, exception types,
and static initialization code. In most cases, Apex classes are modeled on
their counterparts in Java.
Clone
Clone is the name of a button or link that allows you to create a new item
by copying the information from an existing item, for example, a contact
or opportunity.
Cloud Computing
A model for software development and distribution based on the Internet.
The technology infrastructure for a service, including data, is hosted on
the Internet. This allows consumers to develop and use services with
browsers or other thin clients instead of investing in hardware, software,
or maintenance.
Combination Chart
A combination chart plots multiple sets of data on a single chart. Each
set of data is based on a different field, so values are easy to compare. You
can also combine certain chart types to present data in different ways on
a single chart.
Component, Visualforce
Something that can be added to a Visualforce page with a set of tags, for
example, <apex:detail>. Visualforce includes a number of standard
components, or you can create your own custom components.
Component Reference, Visualforce
A description of the standard and custom Visualforce components that
are available in your organization. You can access the component library
from the development footer of any Visualforce page or the Visualforce
Developer's Guide.
Controller, Visualforce
An Apex class that provides a Visualforce page with the data and business
logic it needs to run. Visualforce pages can use the standard controllers
317
Chapter 13: Glossary
that come by default with every standard or custom object, or they can
use custom controllers.
Controller Extension
A controller extension is an Apex class that extends the functionality of a
standard or custom controller.
Controlling Field
Any standard or custom picklist or checkbox field whose values control
the available values in one or more corresponding dependent fields.
Custom App
See App.
Custom Controller
A custom controller is an Apex class that implements all of the logic for
a page without leveraging a standard controller. Use custom controllers
when you want your Visualforce page to run entirely in system mode,
which does not enforce the profile-based permissions and field-level
security of the current user.
Custom Field
A field that can be added in addition to the standard fields to customize
Salesforce.com for your organization’s needs.
Custom Help
Custom text administrators create to provide users with on-screen
information specific to a standard field, custom field, or custom object.
Custom Links
Custom URLs defined by administrators to integrate your Salesforce.com
data with external websites and back-office systems. Formerly known as
Web links.
Custom Object
Custom records that allow you to store information unique to your
organization.
Custom Report Type
See Report Type.
Custom Settings
Custom settings are similar to custom objects and enable application
developers to create custom sets of data, as well as create and associate
custom data for an organization, profile, or specific user. All custom
settings data is exposed in the application cache, which enables efficient
access without the cost of repeated queries to the database. This data can
then be used by formula fields, validation rules, Apex, and the Web services
API.
See also Hierarchy Custom Settings and List Custom Settings.
318
Glossary
Custom S-Control
Note: S-controls have been superseded by Visualforce pages.
After March 2010 organizations that have never created s-controls,
as well as new organizations, won't be allowed to create them.
Existing s-controls will remain unaffected, and can still be edited.
Custom Web content for use in custom links. Custom s-controls can
contain any type of content that you can display in a browser, for example
a Java applet, an Active-X control, an Excel file, or a custom HTML Web
form.
Custom View
A display feature that lets you see a specific set of records for a particular
object.
D
Dashboard
A dashboard shows data from source reports as visual components, which
can be charts, gauges, tables, metrics, or Visualforce pages. They provide
a snapshot of key metrics and performance indicators for your organization.
Each dashboard can have up to 20 components.
Database
An organized collection of information. The underlying architecture of
the Force.com platform includes a database where your data is stored.
Database Table
A list of information, presented with rows and columns, about the person,
thing, or concept you want to track. See also Object.
Data Loader
A Force.com platform tool used to import and export data from your
Salesforce.com organization.
Decimal Places
Parameter for number, currency, and percent custom fields that indicates
the total number of digits you can enter to the right of a decimal point,
for example, 4.98 for an entry of 2. Note that the system rounds the
decimal numbers you enter, if necessary. For example, if you enter 4.986
in a field with Decimal Places of 2, the number rounds to 4.99.
Delegated Administration
A security model in which a group of non-administrator users perform
administrative tasks.
319
Chapter 13: Glossary
Delegated Authentication
A security process where an external authority is used to authenticate
Force.com platform users.
Dependency
A relationship where one object's existence depends on that of another.
There are a number of different kinds of dependencies including mandatory
fields, dependent objects (parent-child), file inclusion (referenced images,
for example), and ordering dependencies (when one object must be
deployed before another object).
Dependent Field
Any custom picklist or multi-select picklist field that displays available
values based on the value selected in its corresponding controlling field.
Detail
A page that displays information about a single object record. The detail
page of a record allows you to view the information, whereas the edit page
allows you to modify it.
A term used in reports to distinguish between summary information and
inclusion of all column data for all information in a report. You can toggle
the Show Details/Hide Details button to view and hide report detail
information.
Developer Edition
A free, fully-functional Salesforce.com organization designed for developers
to extend, integrate, and develop with the Force.com platform. Developer
Edition accounts are available on developer.force.com.
Development as a Service (DaaS)
An application development model where all development is on the Web.
This means that source code, compilation, and development environments
are not on local machines, but are Web-based services.
Development Environment
A Salesforce.com organization where you can make configuration changes
that will not affect users on the production organization. There are two
kinds of development environments, sandboxes and Developer Edition
organizations.
Developer Force
The Developer Force website at developer.force.com provides a full range
of resources for platform developers, including sample code, toolkits, an
online developer community, and the ability to obtain limited Force.com
platform environments.
Document Library
A place to store documents without attaching them to accounts, contacts,
opportunities, or other records.
320
Glossary
E
Email Alert
Email alerts are workflow and approval actions that are generated using
an email template by a workflow rule or approval process and sent to
designated recipients, either Salesforce.com users or others.
Email Template
A form email that communicates a standard message, such as a welcome
letter to new employees or an acknowledgement that a customer service
request has been received. Email templates can be personalized with merge
fields, and can be written in text, HTML, or custom format.
Enterprise Application
An application that is designed to support functionality for an organization
as a whole, rather than solving a specific problem.
Enterprise Edition
A Salesforce.com edition designed for larger, more complex businesses.
Entity Relationship Diagram (ERD)
A data modeling tool that helps you organize your data into entities (or
objects, as they are called in the Force.com platform) and define the
relationships between them. ERD diagrams for key Salesforce.com objects
are published in the Web Services API Developer's Guide.
Event
An event is an activity that has a scheduled time. For example, a meeting,
or a scheduled phone call.
F
Field
A part of an object that holds a specific piece of information, such as a
text or currency value.
Field-Level Security
Settings that determine whether fields are hidden, visible, read only, or
editable for users based on their profiles. Available in Enterprise,
Unlimited, and Developer Editions only.
Field Dependency
A filter that allows you to change the contents of a picklist based on the
value of another field.
Field Update
Field updates are workflow and approval actions that specify the field you
want updated and the new value for it. Depending on the type of field,
you can choose to apply a specific value, make the value blank, or calculate
a value based on a formula you create.
321
Chapter 13: Glossary
Filter Condition/Criteria
Condition on particular fields that qualifies items to be included in a list
view or report, such as “State equals California.”
Folder
A folder is a place where you can store reports, dashboards, documents, or
email templates. Folders can be public, hidden, or shared, and can be set
to read-only or read/write. You control who has access to its contents
based on roles, permissions, public groups, and license types.
Force.com
The salesforce.com platform for building applications in the cloud.
Force.com combines a powerful user interface, operating system, and
database to allow you to customize and deploy applications in the cloud
for your entire enterprise.
Force.com App Menu
A menu that enables users to switch between customizable applications
(or “apps”) with a single click. The Force.com app menu displays at the
top of every page in the user interface.
Force.com IDE
An Eclipse plug-in that allows developers to manage, author, debug and
deploy Force.com applications in the Eclipse development environment.
Web Services API
A SOAP-based Web services application programming interface that
provides access to your Salesforce.com organization's information. See
also Bulk API.
Foreign key
A field whose value is the same as the primary key of another table. You
can think of a foreign key as a copy of a primary key from another table.
A relationship is made between two tables by matching the values of the
foreign key in one table with the values of the primary key in another.
Formula Field
A type of custom field. Formula fields automatically calculate their values
based on the values of merge fields, expressions, or other values.
Function
Built-in formulas that you can customize with input parameters. For
example, the DATE function creates a date field type from a given year,
month, and day.
322
Glossary
G
Global Variable
A special merge field that you can use to reference data in your
organization.
A method access modifier for any method that needs to be referenced
outside of the application, either in the Web services API or by other
Apex scripts.
Group
A groups is a set of users. Groups can contain individual users, other
groups, or the users in a role. Groups can be used to help define sharing
access to data or to specify which data to synchronize when using Connect
for Outlook or Connect for Lotus Notes.
Users can define their own personal groups. Administrators can create
public groups for use by everyone in the organization.
Group Edition
A product designed for small businesses and workgroups with a limited
number of users.
H
Hierarchy Custom Settings
A type of custom setting that uses a built-in hierarchical logic that lets
you “personalize” settings for specific profiles or users. The hierarchy logic
checks the organization, profile, and user settings for the current user and
returns the most specific, or “lowest,” value. In the hierarchy, settings for
an organization are overridden by profile settings, which, in turn, are
overridden by user settings.
Home Tab
Starting page from which users can choose sidebar shortcuts and options,
view current tasks and activities, or select another tab.
Hover Detail
Hover details display an interactive overlay containing detailed information
about a record when users hover the mouse over a link to that record in
the Recent Items list on the sidebar or in a lookup field on a record detail
page. Users can quickly view information about a record before clicking
View for the record's detail page or Edit for the edit page. The fields
displayed in the hover details are determined by the record's mini page
layout. The fields that display in document hover details are not
customizable.
323
Chapter 13: Glossary
HTML S-Control
Note: S-controls have been superseded by Visualforce pages.
After March 2010 organizations that have never created s-controls,
as well as new organizations, won't be allowed to create them.
Existing s-controls will remain unaffected, and can still be edited.
I
ID
See Salesforce.com Record ID.
Integrated Development Environment (IDE)
A software application that provides comprehensive facilities for software
developers including a source code editor, testing and debugging tools,
and integration with source code control systems.
Immediate Action
A workflow action that executes instantly when the conditions of a
workflow rule are met.
Import Wizard
A tool for importing data into your Salesforce.com organization, accessible
from Setup.
Inline S-Control
Note: S-controls have been superseded by Visualforce pages.
After March 2010 organizations that have never created s-controls,
as well as new organizations, won't be allowed to create them.
Existing s-controls will remain unaffected, and can still be edited.
324
Glossary
J
Junction Object
A custom object with two master-detail relationships. Using a custom
junction object, you can model a “many-to-many” relationship between
two objects. For example, you may have a custom object called “Bug” that
relates to the standard case object such that a bug could be related to
multiple cases and a case could also be related to multiple bugs.
K
No Glossary items for this entry.
L
Layout
See Page Layout.
Length
Parameter for custom text fields that specifies the maximum number of
characters (up to 255) that a user can enter in the field.
Parameter for number, currency, and percent fields that specifies the
number of digits you can enter to the left of the decimal point, for example,
123.98 for an entry of 3.
Letterhead
Determines the basic attributes of an HTML email template. Users can
create a letterhead that includes attributes like background color, logo,
font size, and font color.
List View
A list display of items (for example, accounts or contacts) based on specific
criteria. Salesforce.com provides some predefined views.
In the Console tab, the list view is the top frame that displays a list view
of records based on specific criteria. The list views you can select to display
in the console are the same list views defined on the tabs of other objects.
You cannot create a list view within the console.
Locale
The country or geographic region in which the user is located. The setting
affects the format of date and number fields, for example, dates in the
English (United States) locale display as 06/30/2000 and as 30/06/2000
in the English (United Kingdom) locale.
In Professional, Enterprise, Unlimited, and Developer Edition
organizations, a user’s individual Locale setting overrides the
organization’s Default Locale setting. In Personal and Group Editions,
the organization-level locale field is called Locale, not Default
Locale.
325
Chapter 13: Glossary
M
Manual Sharing
Record-level access rules that allow record owners to give read and edit
permissions to other users who might not have access to the record any
other way.
Many-to-Many Relationship
A relationship where each side of the relationship can have many children
on the other side. Many-to-many relationships are implemented through
the use of junction objects.
Master-Detail Relationship
A relationship between two different types of records that associates the
records with each other. For example, accounts have a master-detail
relationship with opportunities. This type of relationship affects record
deletion, security, and makes the lookup relationship field required on the
page layout.
Master Picklist
A complete list of picklist values available for a record type or business
process.
326
Glossary
Matrix Report
Matrix reports are similar to summary reports, but allow you to group and
summarize data by both rows and columns. They can be used as the source
report for dashboard components. Use this type for comparing related
totals, especially if you have large amounts of data to summarize and you
need to compare values in several different fields, or you want to look at
data by date and by product, person, or geography.
Merge Field
A field you can place in an email template, mail merge template, custom
link, or formula to incorporate values from a record. For example, Dear
{!Contact.FirstName}, uses a contact merge field to obtain the value
of a contact record's First Name field to address an email recipient by
his or her first name.
Metadata
Information about the structure, appearance, and functionality of an
organization and any of its parts. Force.com uses XML to describe
metadata.
Mini Page Layout
A subset of the items in a record's existing page layout that administrators
choose to display in the Console tab's Mini View and in Hover Details.
Mini page layouts inherit record type and profile associations, related lists,
fields, and field access settings from the page layout.
Multitenancy
An application model where all users and apps share a single, common
infrastructure and code base.
N
Notes
Miscellaneous information pertaining to a specific record.
O
Object
An object allows you to store information in your Salesforce.com
organization. The object is the overall definition of the type of information
you are storing. For example, the case object allow you to store information
regarding customer inquiries. For each object, your organization will have
multiple records that store the information about specific instances of that
type of data. For example, you might have a case record to store the
information about Joe Smith's training inquiry and another case record
to store the information about Mary Johnson's configuration issue.
327
Chapter 13: Glossary
Object-Level Help
Custom help text that you can provide for any custom object. It displays
on custom object record home (overview), detail, and edit pages, as well
as list views and related lists.
Object-Level Security
Settings that allow an administrator to hide whole tabs and objects from
a user so that he or she does not know that type of data exists. On the
platform you set object-level access rules with object permissions on user
profiles.
One-to-Many Relationship
A relationship in which a single object is related to many other objects.
For example, an account may have one or more related contacts.
Organization
A deployment of Salesforce.com with a defined set of licensed users. An
organization is the virtual space provided to an individual customer of
salesforce.com. Your organization includes all of your data and applications,
and is separate from all other organizations.
Organization-Wide Defaults
Settings that allow you to specify the baseline level of data access that a
user has in your organization. For example, you can make it so that any
user can see any record of a particular object that is enabled in their user
profile, but that they need extra permissions to edit one.
Outbound Message
An outbound message is a workflow, approval, or milestone action that
sends the information you specify to an endpoint you designate, such as
an external service. An outbound message sends the data in the specified
fields in the form of a SOAP message to the endpoint. Outbound
messaging is configured in the Salesforce.com setup menu. Then you must
configure the external endpoint. You can create a listener for the messages
using the Web services API.
Overlay
An overlay displays additional information when you hover your mouse
over certain user interface elements. Depending on the overlay, it will
close when you move your mouse away, click outside of the overlay, or
click a close button.
Owner
Individual user to which a record (for example, a contact or case) is
assigned.
328
Glossary
P
Page Layout
The organization of fields, custom links, and related lists on a record detail
or edit page. Use page layouts primarily for organizing pages for your
users. In Enterprise, Unlimited, and Developer Editions, use field-level
security to restrict users’ access to specific fields.
Picklist
Selection list of options available for specific fields in a Salesforce.com
object, for example, the Industry field for accounts. Users can choose
a single value from a list of options rather than make an entry directly in
the field. See also Master Picklist.
Picklist Values
Selections displayed in drop-down lists for particular fields. Some values
come predefined, and other values can be changed or defined by an
administrator.
Platform as a Service (PaaS)
An environment where developers use programming tools offered by a
service provider to create applications and deploy them in a cloud. The
application is hosted as a service and provided to customers via the Internet.
The PaaS vendor provides an API for creating and extending specialized
applications. The PaaS vendor also takes responsibility for the daily
maintenance, operation, and support of the deployed application and each
customer's data. The service alleviates the need for programmers to install,
configure, and maintain the applications on their own hardware, software,
and related IT resources. Services can be delivered using the PaaS
environment to any market segment.
Platform Edition
A Salesforce.com edition based on either Enterprise Edition or Unlimited
Edition that does not include any of the standard Salesforce.com CRM
apps, such as Sales or Service & Support.
Primary Key
A relational database concept. Each table in a relational database has a
field in which the data value uniquely identifies the record. This field is
called the primary key. The relationship is made between two tables by
matching the values of the foreign key in one table with the values of the
primary key in another.
Printable View
An option that displays a page in a print-ready format.
Private Sharing
Private sharing is the process of sharing an uploaded package by using the
URL you receive from Salesforce.com. This URL is not listed in the
329
Chapter 13: Glossary
Q
Queue
A holding area for items before they are processed. Salesforce.com uses
queues in a number of different features and technologies.
R
Read Only
One of the standard profiles to which a user can be assigned. Read Only
users can view and report on information based on their role in the
organization. (That is, if the Read Only user is the CEO, they can view
all data in the system. If the Read Only user has the role of Western Rep,
they can view all data for their role and any role below them in the
hierarchy.)
Recent Items
List of links in the sidebar for most recently accessed records. Note that
not all types of records are listed in the recent items.
Record
A single instance of a Salesforce.com object. For example, “John Jones”
might be the name of a contact record.
Record ID
See Salesforce.com Record ID.
330
Glossary
Record-Level Security
A method of controlling data in which you can allow a particular user to
view and edit an object, but then restrict the records that the user is allowed
to see.
Record Name
A standard field on all Salesforce.com objects. Whenever a record name
is displayed in a Force.com application, the value is represented as a link
to a detail view of the record. A record name can be either free-form text
or an autonumber field. Record Name does not have to be a unique value.
Record Type
A field available for certain records that can include some or all of the
standard and custom picklist values for that record. Record types are special
fields that you can associate with profiles to make only the included picklist
values available to users with that profile.
Recycle Bin
A page that lets you view and restore deleted information. Access the
Recycle Bin by using the link in the sidebar.
Related List
A section of a record or other detail page that lists items related to that
record. For example, the Stage History related list of an opportunity or
the Open Activities related list of a case.
Related List Hover Links
A type of link that allows you to quickly view information on a detail page
about related lists, by hovering your mouse over the link. Your
administrator must enable the display of hover links. The displayed text
contains the corresponding related list and its number of records. You can
also click this type of link to jump to the content of the related list without
having to scroll down the page.
Related Object
Objects chosen by an administrator to display in the Console tab's mini
view when records of a particular type are shown in the console's detail
view. For example, when a case is in the detail view, an administrator can
choose to display an associated account, contact, or asset in the mini view.
Relationship
A connection between two objects, used to create related lists in page
layouts and detail levels in reports. Matching values in a specified field in
both objects are used to link related data; for example, if one object stores
data about companies and another object stores data about people, a
relationship allows you to find out which people work at the company.
331
Chapter 13: Glossary
Report
A report returns a set of records that meets certain criteria, and displays it
in organized rows and columns. Report data can be filtered, grouped, and
displayed graphically as a chart. See Tabular Report, Summary Report,
and Matrix Report.
Report Type
A report type defines the set of records and fields available to a report based
on the relationships between a primary object and its related objects.
Reports display only records that meet the criteria defined in the report
type. Salesforce.com provides a set of pre-defined standard report types;
administrators can create custom report types as well.
Role Hierarchy
A record-level security setting that defines different levels of users such
that users at higher levels can view and edit information owned by or
shared with users beneath them in the role hierarchy, regardless of the
organization-wide sharing model settings.
Roll-Up Summary Field
A field type that automatically provides aggregate values from child records
in a master-detail relationship.
Running User
Each dashboard has a running user, whose security settings determine
which data to display in a dashboard. If the running user is a specific user,
all dashboard viewers see data based on the security settings of that
user—regardless of their own personal security settings. For dynamic
dashboards, you can set the running user to be the logged-in user, so that
each user sees the dashboard according to his or her own access level.
S
SaaS
See Software as a Service (SaaS).
S-Control
Note: S-controls have been superseded by Visualforce pages.
After March 2010 organizations that have never created s-controls,
as well as new organizations, won't be allowed to create them.
Existing s-controls will remain unaffected, and can still be edited.
Custom Web content for use in custom links. Custom s-controls can
contain any type of content that you can display in a browser, for example
a Java applet, an Active-X control, an Excel file, or a custom HTML Web
form.
332
Glossary
Salesforce.com Record ID
A unique 15- or 18-character alphanumeric string that identifies a single
record in Salesforce.com.
Sandbox Organization
A nearly identical copy of a Salesforce.com production organization. You
can create multiple sandboxes in separate environments for a variety of
purposes, such as testing and training, without compromising the data
and applications in your production environment.
Save As
Option on any standard, public, or custom report to save the parameters
of the report without altering the original report. It creates a new custom
report with your saved changes.
Save & New
Alternative “save” on most pages with which you can save your current
changes and create a new entry.
Search
Feature that lets you search for information that matches specified
keywords. If you have Sidebar Search, enter search terms in the Search
section of the sidebar or click Advanced Search... for more search options.
If you have Global Search, enter search terms in the search box in the
header.
Search Layout
The organization of fields included in search results, in lookup dialogs,
and in the key lists on tab home pages.
Setup
An administration area where you can customize and define Force.com
applications. Access Setup through the Your Name ➤ Setup link at the
top of Salesforce.com pages.
Sharing
Allowing other users to view or edit information you own. There are
different ways to share data:
• Sharing Model—defines the default organization-wide access levels
that users have to each other’s information and whether to use the
hierarchies when determining access to data.
• Role Hierarchy—defines different levels of users such that users at
higher levels can view and edit information owned by or shared with
users beneath them in the role hierarchy, regardless of the
organization-wide sharing model settings.
• Sharing Rules—allow an administrator to specify that all information
created by users within a given group or role is automatically shared
to the members of another group or role.
333
Chapter 13: Glossary
T
Tab
A tab is an interface component that allows you to navigate around an
app. A tab serves as the starting point for viewing, editing, and entering
information for a particular object. When you click a tab at the top of the
page, the corresponding tab home page for that object appears. A tab can
be associated with an object, a Web page, or a Visualforce page.
Tabular Report
Tabular reports are the simplest and fastest way to look at data. Similar
to a spreadsheet, they consist simply of an ordered set of fields in columns,
with each matching record listed in a row. Tabular reports are best for
creating lists of records or a list with a single grand total. They can't be
used to create groups of data or charts, and can't be used in dashboards
unless rows are limited. Examples include contact mailing lists and activity
reports.
Task
Assigns a task to a user you specify. You can specify the Subject,
Status, Priority, and Due Date of the task. Tasks are workflow and
approval actions that are triggered by workflow rules or approval processes.
For Calender-related tasks, see Activity (Calendar Events/Tasks).
Text
Data type of a custom field that allows entry of any combination of letters,
numbers, or symbols, up to a maximum length of 255 characters.
335
Chapter 13: Glossary
Text Area
A custom field data type that allows entry of up to 255 characters on
separate lines.
Text Area (Long)
See Long Text Area.
Time-Dependent Workflow Action
A workflow action that executes when the conditions of a workflow rule
and an associated time trigger are met.
Time Trigger
An event that starts according to a specified time threshold, such as seven
days before an opportunity close date. For example, you might define a
time-based workflow action that sends email to the account manager when
a scheduled milestone will occur in seven days.
U
Unlimited Edition
Unlimited Edition is salesforce.com's flagship solution for maximizing
CRM success and extending that success across the entire enterprise
through the Force.com platform.
URL (Uniform Resource Locator)
The global address of a website, document, or other resource on the
Internet. For example, http://www.salesforce.com.
URL S-Control
Note: S-controls have been superseded by Visualforce pages.
After March 2010 organizations that have never created s-controls,
as well as new organizations, won't be allowed to create them.
Existing s-controls will remain unaffected, and can still be edited.
An s-control that contains an external URL that hosts the HTML that
should be rendered on a page. When saved this way, the HTML is hosted
and run by an external website. URL s-controls are also called Web
controls.
User Interface
The layouts that specify how a data model should be displayed.
V
Validation Rule
A rule that prevents a record from being saved if it does not meet the
standards that are specified.
336
Glossary
Visualforce
A simple, tag-based markup language that allows developers to easily
define custom pages and components for apps built on the platform. Each
tag corresponds to a coarse or fine-grained component, such as a section
of a page, a related list, or a field. The components can either be controlled
by the same logic that is used in standard Salesforce.com pages, or
developers can associate their own logic with a controller written in Apex.
Visualforce Controller
See Controller, Visualforce.
Visualforce Page
A web page created using Visualforce. Typically, Visualforce pages present
information relevant to your organization, but they can also modify or
capture data. They can be rendered in several ways, such as a PDF
document or an email attachment, and can be associated with a CSS style.
W
Web Control
See URL S-Control.
Web Links
See Custom Links.
Web Service
A mechanism by which two applications can easily exchange data over
the Internet, even if they run on different platforms, are written in different
languages, or are geographically remote from each other.
Web Tab
A custom tab that allows your users to use external websites from within
the application.
Wizard
A user interface that leads a user through a complex task in multiple steps.
Workflow and Approval Actions
Workflow and approval actions consist of email alerts, tasks, field updates,
and outbound messages that can be triggered by a workflow rule or
approval process.
Workflow Action
An email alert, field update, outbound message, or task that fires when
the conditions of a workflow rule are met.
Workflow Email Alert
A workflow action that sends an email when a workflow rule is triggered.
Unlike workflow tasks, which can only be assigned to application users,
337
Chapter 13: Glossary
workflow alerts can be sent to any user or contact, as long as they have a
valid email address.
Workflow Field Update
A workflow action that changes the value of a particular field on a record
when a workflow rule is triggered.
Workflow Outbound Message
A workflow action that sends data to an external Web service, such as
another cloud computing application. Outbound messages are used
primarily with composite apps.
Workflow Queue
A list of workflow actions that are scheduled to fire based on workflow
rules that have one or more time-dependent workflow actions.
Workflow Rule
A workflow rule sets workflow actions into motion when its designated
conditions are met. You can configure workflow actions to execute
immediately when a record meets the conditions in your workflow rule,
or set time triggers that execute the workflow actions on a specific day.
Workflow Task
A workflow action that assigns a task to an application user when a
workflow rule is triggered.
X
XML (Extensible Markup Language)
A markup language that enables the sharing and transportation of
structured data. All Force.com components that are retrieved or deployed
through the Metadata API are represented by XML definitions.
Y
No Glossary items for this entry.
Z
Zip File
A data compression and archive format.
A collection of files retrieved or deployed by the Metadata API. See also
Local Project.
338
Index
Index
__c suffix 36, 47 Approval actions (continued)
* search wildcard 113 See also Workflow actions 221
Approval History related list 217, 226
Approval processes 10, 210
A actions 210
About this book 2 activating 224
Actions, approval approving and rejecting records 227
See Approval actions 221 creating 213
Actions, workflow delegate approvers 218
See Workflow actions 187 history information 216
Activating Items to Approve related list 227
approval processes 224 jump-start vs. standard setup 213
time-dependent workflow 203 multiple approvers 220
workflow rules 194 page layouts 215
Activities, enabling for custom objects 37 planning 212
Administration record editability 214
delegating 179 Recruiting app 19
setup area 30 related users 220
Administrative permissions Submit for Approval button 225
global 179 testing 224
Advanced formula editor 64 visualizer 224
Alerts, workflow wireless devices 216
See Workflow email alerts 188 Approval steps
Amazon.com 2 about 217
Analytics approval and rejection actions 219
See Reports 230 creating 218
AND() function 72 designating an approver 218
Apex ordering 218
about 14, 277 Approving records 227
API Apps
__c suffix 36, 47 about 30
about 13, 275 basic elements 8
documentation 311 benefits 9
field labels vs. names 47 building iteratively 33
labels vs. names, field 47 cloud computing 1
labels vs. names, object 36 collaborative 10
name 62 creating 31
object labels vs. names 35 custom app wizard 31
App setup area 30 data-centric 9
AppExchange 15 databases 22
partner program 313 debugging 34
Approval actions default tab display 139
about 221 detail pages 8
creating 222 distributing on AppExchange 15
edit pages 8
339
Index
H K
Help and training options 312 Keys
Hierarchical relationship fields 214 foreign 114
Hierarchies, role primary and foreign 27
See Role hierarchies 134
Highlighting, conditional
See Conditional highlighting 251 L
Hiring Manager profile 142
History tracking, field Labels vs. names
enabling for custom objects 37 field 35, 47
History, approval process 216 object 35, 47
Layout, list view button 99
343
Index
349