Force.com Developer Certification Handbook (DEV401)

  • 41 632 9
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up

Force.com Developer Certification Handbook (DEV401)

Force.com Developer Certification Handbook (DEV401) A comprehensive handbook to guide Force.com developers through impor

1,140 611 6MB

Pages 280 Page size 612 x 792 pts (letter) Year 2012

Report DMCA / Copyright

DOWNLOAD FILE

Recommend Papers

File loading please wait...
Citation preview

Force.com Developer Certification Handbook (DEV401) A comprehensive handbook to guide Force.com developers through important fundamentals and prepare them for the DEV401 exam

Siddhesh Kabe

professional expertise distilled

P U B L I S H I N G

BIRMINGHAM - MUMBAI

Force.com Developer Certification Handbook (DEV401) Copyright © 2012 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: January 2012

Production Reference: 1200112

Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-84968-348-7 www.packtpub.com

Cover Image by Artie Ng ([email protected])

Credits Author Siddhesh Kabe Reviewers Ankit Arora

Project Coordinator Vishal Bodwani Proofreader Ting Baker

Matthew Botos John Rotenstein Acquisition Editor Dhwani Devater Lead Technical Editor Hithesh Uchil Technical Editor Merwine Machado

Indexer Rekha Nair Graphics Manu Joseph Production Coordinator Nilesh R. Mohite Cover Work Nilesh R. Mohite

About the Author Siddhesh Kabe has been enamored with the world wide web since his college

days. In those days he started designing websites as a hobby and learnt HTML, CSS, SEO, and other web technologies. In 2008 he found out about the magical cloud platform of Force.com. On Force.com he has worked as a Technical Analyst and Consultant on many custom applications for end-users. He has also trained many young developers and end-users about Force.com. He owns an active blog on Force. com (http://force.siddheshkabe.co.in) where he shares tips and information on the platform. He is an active member of the Force.com community and frequently visits the developer forums helping the community and is the leader of the Force. com Pune Users Group. Based in Pune (India), he completed his Bachelor of Engineering Degree at Pune University with specialization in Computer Science. In his spare time, he writes stories and draws cartoons. Siddhesh can be reached through twitter (@_siddhesh) or his site http://siddheshkabe.co.in.

Acknowledgement I would like to thank the team at Packt Publishing for giving me the opportunity to write this book. Thanks to Newton Sequeira for identifying me to work on this project, and to my editors Dhwani Devater and Hithesh Uchil, for dealing with the bad drafts and encouraging me. Special thanks to Vishal Bodwani, the project coordinator of the book, for keeping his cool and putting up with me, even though I kept missing deadline after deadline. I would like to thank the mentors I met on this journey of Force.com, who helped and guided me at different stages on Force.com. Without their guidance I would not be where I am today. I would like to specially mention Aruna Lambat for helping me to prepare the problem statement of the Library Management System cited in the book and Santosh R. Kumbar for developing it based on the requirements. Finally, I would like to thank the people closest to me, my mom, Shobhana Kabe, my dad, Govind Kabe, and my brother, Chaitanya Kabe, for being supportive and patient while I stayed up all night to complete this book. I would also like to thank my girlfriend, Deepika Kalyani, for being supportive for the duration of this book. No book on Force.com can be complete without mentioning the amazing developer community and the Force.com team itself; thank you for the great cloud platform and the developer blogs that have helped us from time to time.

About the Reviewers Ankit Arora is an avid Force.com developer who has worked on the platform since

2009. He is quite new in the IT industry as he is a 2008 graduate in Computer Science engineering. He started his career as a Java developer and later shifted his focus to cloud computing in 2009. He is highly passionate about the cloud and ranks Force.com as number one. He is DEV401 certified and has won online challenges rolled out by Salesforce.com such as TwitterTrivia, Hammer of Thor, and so on. He is acknowledged as a moderator on the Salesforce developer forums and he regularly blogs about tips and tricks, concepts and ideas on Force.com at http://forceguru.blogspot.com. His submitted and accepted recipes can be found in the online Force.com cookbook. He is right now in the process of co-authoring a book on Force.com tips and tricks, which will be aimed at making life easier for developers and administrators by exposing them to things that are either not documented or have been learnt by hard experience.

Ankit works for Metacube, its expertise lies in creating products and services for enterprises that leverage the converging technologies of cloud computing, mobile networks, and handheld devices to translate their ideas into products, the cloud being the main strategic focus area. Metacube has gained rich experience in building and implementing on demand applications and plans to leverage this early mover advantage to help more organizations build new software products and services based on the SaaS model, migrating existing products to the cloud and implementing custom cloud-based solutions. Ankit resides in Jaipur, also known as the pink city, located in Rajasthan, India, a city that has been able to maintain its rich heritage from the times of Maharajas, and at the same time picked up the development pace to emerge as a strong contender for to be one of the fastest growing cities in India. He is still a bachelor, lives with his family and likes to play first person combat games such as Counter Strike in his free time. He is an enthusiast sportsman and a national level player in the online Counter Strike competition.

Matthew Botos is a strategic technical leader with a deep understanding of software development and a passion for building better products. Holding advanced degrees from Cornell University and Penn State, he has been a key contributor to projects in the defense, pharmaceutical, and consumer product industries. He is both a Force.com Certified Developer and one of only 75 professionals in the world to earn the Force. com Certified Advanced Developer certification. In his current role as Mobile Development Manager at Mavens Consulting, Matthew has built a new line of business pairing the growing demand for mobile life sciences applications with the cost-effective cloud technology of Salesforce.com. Mavens' customers include 7 of the top 10 global pharmaceutical companies, with implementations including mobile, Force.com sites, Customer Portal, Service Cloud, integration, and custom apps. As a conference speaker, Matthew has been invited to events including iPhoneDevCon and Dreamforce, where he has presented the topics such as mobile development, security, and Salesforce.com integration.

John Rotenstein is a Force.com developer living in Sydney, Australia. He writes a popular Force.com blog at theEnforcer.net, where he shares his technical experience about managing and developing on the Salesforce platform. He is a Salesforce Administrator at Atlassian, an Australian software company that makes development and collaboration systems.

www.PacktPub.com Support files, eBooks, discount offers and more You might want to visit www.PacktPub.com for support files and downloads related to your book.

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@ packtpub.com for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

http://PacktLib.PacktPub.com Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books. 

Why Subscribe? • • •

Fully searchable across every book published by Packt Copy and paste, print and bookmark content On demand and accessible via web browser

Free Access for Packt account holders

If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.

Instant Updates on New Packt Books

Get notified! Find out when new books are published by following @PacktEnterprise on Twitter, or the Packt Enterprise Facebook page.

This book is dedicated to my late uncle, Umesh Mahambre, who used to take me to his newspaper office as a child and taught me my first few lessons in writing.

Table of Contents Preface Chapter 1: Getting Started with Force.com

1 9

The cloud computing model of Force.com Understanding the Force.com model Force.com platform Model-View-Controller architecture Key technology behind the Force.com platform

10 11 12 13 14

Force.com development Force.com metadata Metadata API Online page editor and Eclipse Force.com IDE

18 18 19 19

Multi-tenant kernel Force.com metadata Force.com Webservice API Apex and Visualforce AppExchange Force.com sites

Sandbox

14 15 15 15 17 17

20

Force.com application types Developing on the Force.com platform

22 22

Exercise – creating a developer account Authentication on Force.com Exercise – changing your e-mail address Exercise – adding trusted IP addresses Exercise – resetting security tokens Developer.Force.com Summary Test your knowledge

25 26 26 27 28 28 30 30

Declarative development Programmatic development When to use what

23 24 24

Table of Contents

Chapter 2: Creating a Database on Force.com Library Management System Requirements Objects Exercise – creating an object Force.com data types Custom fields Text fields Picklists Dependent picklist

Exercise – creating a dependent picklist

33 33 34 35 36 40 41 41 42 42

42

Currency field Other fields Field options

44 45 45

Required field Unique field Encrypted field

45 46 47

Relationships Lookup (1:n) Master-Detail relationship (1:n) Special relationships

49 49 50 51

Summary Test your knowledge

53 53

Exercise – creating a junction object Exercise – building the data model for the Library Management System

Chapter 3: User Interface

What is an application? Understanding a custom application Exercise – building your own application

Custom tabs

52 52

57 57 58

59

60

Exercise – creating custom tabs Page layouts Page layout editor Using the page layout editor Sections and blank spaces Custom buttons and links Field options Editing other layouts

62 63 65 65 67 69 72 72

Mini page layout Overview of Visualforce Visualforce content Key components of Visualforce

74 75 75 76 [ ii ]

Table of Contents Pages Standard components Controllers

Data binding in Visualforce Using the Visualforce pages in the organization Visualforce tags Binding tags with data and Apex

76 76 76

78 79 79

80

Visualforce component library

81

Standard Salesforce components

85

AJAX and JavaScript in Visualforce

88

Inline Visualforce on page layouts

89

Layout components Other layout components

82 84

Data components Output components Input components AJAX components Static resources

85 85 86 88 90

Summary Test your knowledge

Chapter 4: Implementing Business Logic

The basic rules of implementing business logic Rule syntax Validation rules Exercise – creating a validation rule

Formula fields

90 91

93 93 94 95

97

98

Exercise – calculating the return date

99

Cross object formula fields

101

Roll-up summary fields

104

Exercise – calculating penalty

101

Exercise – creating the roll-up summary

104

Using workflows to automate business processes Exercise – sending e-mail to members Time-dependent workflow

106 107 111

Improving productivity using an automated approval process Creating a multi-step approval process Creating approval steps Approval actions Parallel approval step Comparing workflow and the approval process Debugging and monitoring the process

113 114 116 117 119 120 121

Exercise – blacklisting the member Exercise – creating multiple time-based triggers

[ iii ]

111 113

Table of Contents

Types of logs

121

Debug log System logs

Categories of logs Log levels in the system log console Using the debug log Summary Test your knowledge

Chapter 5: Data Management

The basics of data operations The importance of record IDs 18-character and 15-character IDs Exploring the URL format Record ID Summarizing record IDs Relationships — dependents first Modifying system fields Features of modifiable system fields Connecting to the Salesforce server through API The CRUD commands External IDs

122 123

123 124 124 125 125

129 129 130 130 131 132 134 135 136 137 137 137

138

Exercise – migrating data from a legacy system Data loading tools Cloud-based data import wizard Apex data loader

139 139 139 143

Apex data loader versus the cloud-based import wizard Other data manipulation wizards Mass transfer records Mass delete record and delete all data Data storage limit Summary Test your knowledge

154 155 155 158 159 160 160

Downloading the data loader Using the data loader Upserting data Setting up the data loader Using data loader through the command line Troubleshooting the data loader

Chapter 6: Analytics and Reporting

Displaying tabular data using Reports Creating a report Report builder overview

[ iv ]

144 144 146 150 151 154

163 163 165

168

Table of Contents Other options

Scheduling a report Custom report types Self study exercise – create a report Self study exercise – schedule the report Self study exercise – some more reports Displaying graphical charts using dashboards Dashboard builder Combination charts Dashboard security Dashboard folder

Dashboard running user Scheduling a dashboard refresh

Self study exercise — create a dashboard

Analytic snapshot Setting up analytical snapshot Summary Test your knowledge

Chapter 7: Application Administration

Managing access control Force.com licenses Types of licenses Feature licenses Using queues to balance workloads Localization with the translation workbench Setting up the translation workbench Restricting data access Exercise – defining actors Exercise – creating the CRUD diagram Security pyramid User security Exercise – creating a user Password policies

173

173 175 178 179 179 179 180 183 183

183

185 186

188

188 188 192 192

195 195 196 198 199 199 200 201 203 204 205 206 207 208

209

Roles and profiles

210

Quick bites

220

Understanding profiles Assigning roles Exercise – scaling the Library Management System Organization-wide defaults Permission sets Sharing rules Manual sharing

[v]

211 213 215 216 218 218 220

Table of Contents

Setting up security Summary Test your knowledge

221 221 221

Chapter 8: Exam Guide and Practice Paper

223

Appendix A: Sample Paper Answers Appendix B: Chapter-wise Solutions

243 247

Index

251

Overview of the Salesforce Certified Developer Exam Certification maintenance and releases Sample paper Additional resources Official Salesforce resources Community resources Summary

Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7

[ vi ]

223 224 224 239 240 240 241

247 247 248 248 248 249 249

Preface Everything should be as simple as it is, but not simpler.

Albert Einstein (1879 -1955)

Tim Burnett Lee envisioned the Internet as a medium for the quickest exchange of the information and research papers. Did he imagine that the little idea would grow as the largest network of information for humanity. We will never know. But the little NeXT computer that hosted the world's first site would feel proud that its network has become the largest storage of data and the fastest medium for transferring the information across geographies. The past few decades have seen a paradigm shift in the way of developing applications. Earlier we were talking about upgrades, patches, and releases, now we are talking about apps, feeds, and mobility. The Internet has changed the way we see the world. We do not wait for the next service pack to fix the bug that the software provides; we now wait for the next amazing thing the software will bring with it. This is the modern world, the world of cloud computing, the world where the traditional business user does not worry about servers, network routers, hardware accelerators, but simply thinks about ROIs and automating their business processes. When migrating to the new wave of cloud-based applications, we now think about business logic, we think about automating processes, and we think about how we can make the systems better. Force.com is a cloud-based platform that is used to build and deploy enterprise applications on the cloud with minimum coding. Demand for Force.com experts is growing rapidly and companies look for certified professionals. This book comes in handy when you are seeking to pass the Salesforce. com Certified Force.com Developer Exam.

Preface

The Force.com Developer Certification Handbook is a practical guide for you to become a Salesforce.com Certified Force.com developer. This book will help you to impress your colleagues with excellent Force.com skills, and prepare for the DEV401 certification exam. From building applications to automating business processes everything is covered from the certification perspective, and you will gain hands-on expertise with the step-by-step approach of this book. It will help you build and deploy a complete application on Force.com by using point-and-click. With this book you will learn to create and manage custom objects and their data. You will build the user interface for your applications and automate your business process by using workflows and approvals.

Cloud computing

Cloud computing is a broad term used to define infrastructure, platform, software, and data storage hosted on a remote server. The end-user pays for what he uses and not the whole system. The National Institute of Standards and Technology (NIST) defines cloud computing as:

"Cloud computing is a model for enabling convenient, on-demand network access to a shared pool of configurable computing resources (e.g., networks, servers, storage, applications, and services) that can be rapidly provisioned and released with minimal management effort or service provider interaction." For those who do not know, in network diagrams a "Cloud" was used to denote the Internet. The term caught on and cloud computing was born. The term cloud computing is relatively new, but unknowingly we have been using the cloud since 1996 when Hotmail and other web-based e-mail systems were used. Today, we deploy enterprise applications such as Salesforce.com CRM, Zoho CRM, and Google Apps Enterprise Suite on cloud. People do not download or install anything, they simply use it for the duration they want and move on.

[2]

Preface

Types of cloud

The cloud service providers are classified based on the service they provide. They are broadly classified into three different parts. The following figure shows the cloud computing pyramid:

The pyramid defines the flexibility users get in each category when they use the services. As we go from top to bottom, the flexibility provided to the users increases. Let us quickly glance at the three categories mentioned in the pyramid. 1. Software as a Service (SaaS): In this category the vendor provides very little or no customization to the user at all. The software is prebuilt and the user pays for what he uses. The applications built in this way cannot be changed or provide minimum options to customize. Examples of SaaS application are Salesforce.com CRM, Zoho Writer, Google Docs, web-based e-mail, Dropbox, Evernote, and so on. 2. Platform as a Service (PaaS): In this category the developers can develop their own custom applications on the platform provided by the vendor. The platforms have got maximum customization and also provide a web-based editor for the code. Examples of PaaS applications are Force.com, Google App Engine, WaveMaker, and so on. 3. Infrastructure as a Service (IaaS): These cloud services rent out the hosting infrastructure and web farms for use. The code is migrated to their servers, used and deployed like the traditional web hosting space. These services provide APIs and other libraries to help developers write their own applications. Examples of IaaS application are Amazon ECS, RackSpace, GoGrid, and so on. [3]

Preface

What this book covers

Chapter 1, Getting Started with Force.com, explains Force.com and different editions of Force.com. We will be looking at the Force.com platform. We will see the different types of applications possible on Force.com and finally we will open the first developer playground to create applications. Chapter 2, Creating a Database on Force.com, will tell us how to create the data objects on the Force.com platform. It will explain the Force.com terminologies such as 'object' and field and how a relationship can be created between two objects. It will also explain the different kinds of fields that can be created in an object. Chapter 3, User Interface, explains how to create the user interface for the objects created in the previous chapter and how users can view the data, add new records, or modify or delete existing records. This chapter will also introduces Visualforce at a high level. It defines when Visualforce can be used, what are the benefits and the capabilities of Visualforce. Chapter 4, Implementing Business Logic, will explain how business logic can be implemented in the application using various features of Force.com such as formulae, validation rules, workflow rules, and application processes. This chapter will also introduce Apex, which is a Force.com platform programming language that allows developers to write programs and codes based on their business requirements. Chapter 5, Data Management, explains how to manage data in Force.com applications, how to load existing data using various tools such as import wizard and data loader, and how to bulk update or clean data already inside the Force.com objects. It will also explain the record ID in Force.com and the importance and usage of record IDs. Chapter 6, Analytics and Reporting, covers how to create reports and dashboards based on the data stored in Force.com. It covers how to group data, apply filters, create graphs, and charts. Chapter 7, Application Administration, explains the security of Force.com applications. We discuss the three-fold security of the Salesforce system. It also covers creating roles, profiles, restricting a user's access, viewing log files to debug and troubleshoot the application. It will also explain the object level, field level, and record level security. We will also learn how to build applications that are automatically scaled from few to many users. Chapter 8, Exam Guide and Practice Paper, is a brief chapter to give an overview of the exam and help you mentally prepare for what is coming.

[4]

Preface

What you need for this book The prerequisites for the Force.com platform are: • Basic knowledge of Internet/websites • A free Developerforce account (if you don't possess one, the procedure to open one is mentioned in Chapter 1, Getting Started with Force.com) • Zeal to learn • Don't Panic

Who this book is for

Developers who need to prepare for the Salesforce.com Certified Force.com Developer Exam will benefit from this book. This book is ideal for developers who are new to Salesforce CRM and the Force.com platform. It would be advantageous if readers have some familiarity with Salesforce applications and have basic HTML and XML skills. By the end of the book, you will be ready to appear for the exam and develop various applications on the cloud platform.

Reading this book

This book is a practical guide that will help you discover fundamentals for building applications on Force.com without writing a single line of code. If you are new to the Force.com platform and want to learn from scratch, it is advisable that you begin with the first chapter and move on to the last. However, if you are familiar with Force.com and want to understand in detail some aspect of it, you can dip into any chapter. Each certification module is covered in a separate chapter, and is accompanied by questions being asked in the exams. The book is written in the units of the DEV401 exam. If you have been working on the Force.com platform for more than a year now and are preparing for the DEV401 exam, you can directly skip to the section you are weak in and read it. There is a small exercise at the end of the chapter as well as a sample paper in the final chapter. If you have relatively little experience on Force.com or wish to strengthen your skills, you can begin from the first chapter and complete the entire Library Management System example.

[5]

Preface

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning. Code words in text are shown as follows: " We can reference a static resource by name in page markup by using the $Resource global variable instead of hard-coding document IDe." A block of code is set as follows:



New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "The Component Reference is the best place to explore different components and their uses". Warnings or important notes appear in a box like this.

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of. To send us general feedback, simply send an e-mail to [email protected], and mention the book title via the subject of your message. If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail [email protected]. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors. [6]

Preface

Customer support

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

Downloading the example code

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

Errata

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

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy. Please contact us at [email protected] with a link to the suspected pirated material. We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at [email protected] if you are having a problem with any aspect of the book, and we will do our best to address it. [7]

Getting Started with Force.com We have seen what cloud computing is and how it is different than the normal software development. We have seen the different types of models, SaaS, PaaS, and IaaS used with cloud computing. This chapter will introduce you to the Force.com platform. We will understand the life cycle of an application build using Force.com. We will define the multi-tenant architecture and understand how it will impact the data of the organization stored on the cloud. And finally, we will build our first application on Force.com. The agenda for this chapter is as follows: •

The cloud computing model of Force.com



Understand the PaaS model of Force.com



Application development on Force.com



Maintenance and releases



Types of Force.com applications



When to use point-and-click and when to use code



Identity confirmation



Developer resources

So let's get started and step into the cloud...

Getting Started with Force.com

The cloud computing model of Force.com

Force.com provides a 100 percent cloud computing model for enterprise application. The end-user does not have to worry about networks, hardware, software licenses, and so on. Everything is done on the cloud. The following features of Force.com make it a 100 percent cloud-based system: •

Multi-tenant architecture: The multi-tenant architecture is a way of serving multiple clients on the single software instance. Each client gets their own full version of the software configuration and data. They cannot utilize the other instance resources. The software is virtually partitioned into different instances. The basic structure of the multi-tenant architecture is as shown in the following image:

Just like tenants in a single building share the resources of electricity and water, the multi-tenant system shares common resources. Separate programs are written to ensure that a single instance does not monopolize the resources. •

Automatic upgrades: The newer version of the application is released automatically with all the users. Any developments or customizations made during the previous version are automatically updated to the latest version without any manual modification to the code. [ 10 ]

Chapter 1



Subscription model: Force.com is distributed under the subscription model. The user can purchase a few licenses and build the system. After the system is up and successful, further user licenses can be purchased from Salesforce. This model ensures that there no large start-up fee and we pay as we go, which adds fixed, predictable costs in the future. The subscription model can be visualized like the electricity distribution system. We pay for whatever electricity we use and not the complete generator and the infrastructure.



Scalability: The multi-tenant kernel is already tested and running for many users simultaneously. If the organization is growing, there is always room for scaling the application with new users without worrying about the load balancing and data limitation. Force.com provides data storage per user, which means that the data storage increases with the number of users added to the organization.



Upgrades and maintenance: Force.com releases three updated versions every year. The new releases consist of feature updates to Salesforce.com and the Force.com platform with selected top ideas from IdeaExchange. IdeaExchange is the community of Salesforce users where the users submit ideas and the community votes for them. The most popular ideas are considered by Salesforce in their next release.

All the instances hosted on the servers are upgraded with no additional cost. The sandboxes are upgraded early so there can be testing for compatibility to the new release. The new releases are backward compatible with previous releases, thus the old code will work with new versions. The upgrades are taken care of by Force.com and the end-user gets the latest version running application.

Understanding the Force.com model

Force.com offers a platform for development of business applications on the cloud. The platform is offered as a service, where we pay for only those things that are used and not for the entire server and hardware stack. The platform offers many built-in and point-and-click tools for rapid development of applications. Let's take a detailed look at the services forming the platform offered by Force.com. The following section provides us with an overview of the Force.com platform.

[ 11 ]

Getting Started with Force.com

Force.com platform

Force.com is the world's first platform, where end-users can build, share and run an application on the cloud. The Force.com platform runs in a hosted multi-tenant environment, which gives the end-users freedom to build their custom application without hardware purchases, database maintenance and maintaining a software license. Salesforce.com provides three default applications built and hosted on Force. com. They include: 1. Salesforce Automation, Sales Cloud 2. Service and Support Center, Service Cloud 3. Collaboration Center, Chatter The following figure shows the Force.com platform:

The application built on Force.com is automatically hosted on the cloud platform. It can be used separately (without the standard Sales, Service, and Marketing cloud) or can be used in parallel with the existing Salesforce application. The users can access the application using a browser from any mobile, computer, tablet and any of the operating system such as Windows, UNIX, or Mac and so on, giving them complete freedom of location.

[ 12 ]

Chapter 1

The hosted environment also ensures that the software is automatically updated to the latest releases, whether it is Salesforce CRM or a custom application build on Force.com platform. The automatic update automatically upgrades any code or components used by the custom application. As the applications hosted on the Force.com platform have access to a large pool of shared cloud resources, they can be easily scaled to millions of users without significant developer changes.

Model-View-Controller architecture

The key to building any successful business application is a powerful yet loosely coupled Model-View-Controller (MVC) architecture. The MVC architecture ensures that we separate the complex business logic from the UI and the database. This loosely coupled system also helps working in a team. It is also easy to upgrade part of the system without disturbing the entire structure. The following figure illustrates the model-view-controller of Force.com:

The complex business process logic is written inside the controller. The real-life business problems are programmed into powerful data manipulation algorithms. The business logic is separated from the back-end database and the front-end user interface. Force.com uses workflows, Apex triggers, and Apex controllers as the controller in the MVC architecture. The view forms the user interface of the system. This gives the designers the best chance of optimizing the complex data coming from the controller in a human readable form. Force.com uses Visualforce pages, sites, and standard UI (including buttons, forms, tabs, and page views) to define a view. The backbone of this loosely coupled system forms the model or the database. This powerful database system is offered as the bridges between view and controller. Data is wrapped in the model and send to the UI for display. [ 13 ]

Getting Started with Force.com

The metadata, Salesforce objects, Apex objects, and Database.com schema form the model layer of Force.com We will be looking in detail at each layer in the MVC architecture in the subsequent chapters.

Key technology behind the Force.com platform

Force.com is a hosted multi-tenant service used to build custom cloud computing application. It is a 100 percent cloud platform where we pay no extra cost for the hardware and network. Any application built on Force.com is directly hosted on the cloud and can be accessed using a simple browser from a computer or a mobile. The Force.com platform consists of some basic key technologies.

Multi-tenant kernel

The base of the platform forms a multi-tenant kernel, where all users share a common codebase and physical infrastructure. The multiple tenants, who are hosted on a shared server, share the resources under governor limits to prevent a single instance monopolizing the resources. The custom code and data are separated by software virtualization and users cannot access each other's code. The multi-tenant kernel ensures that all instances are updated to the latest version of the software simultaneously. The updates are applied automatically without any patches or software download. The multi-tenant architecture is already live for one million users. This helps developers easily scale the applications from one to a million users with little or no modification. The following image illustrates the multi-tenant architecture:

[ 14 ]

Chapter 1

Traditional software systems are hosted on a single-tenant system, usually a client-server based enterprise application. With the multi-tenant architecture, the end-user does not have to worry about the hardware layer or software upgrade and patches. The software system deployed over the Internet can be accessed using a browser from any location possible, even wide ranges of mobile devices. The multi-tenant architecture also allows the applications to be low cost, quick to deploy, and open to innovation. Other examples of software using multi-tenant architecture are webmail systems such as www.Gmail.com, www.Yahoo.com, and online storage systems such as www.Dropbox.com, or note-taking applications such as Evernote, Springpad, and so on.

Force.com metadata

Force.com is entirely metadata driven. The metadata is defined in XML and can be extracted and imported. We will look into metadata in detail later in this chapter.

Force.com Webservice API

The data and the metadata stored on the Force.com server can be accessed programmatically through the Webservice API. This enables the developers to extend the functionality to virtually any language, operating system, and platform possible. The web services are based on open web standards such as SOAP XML and JSON REST, and are directly compatible with other technologies such as .Net, JAVA, SAP, and Oracle. We can easily integrate the Force.com application with the current business application without rewriting the entire code.

Apex and Visualforce

Apex is the world's first on-demand language introduced by Salesforce. It is an object-oriented language very similar to C# or JAVA. Apex is specially designed for processing large amounts of data for business applications. Apex is used to write the controller in the MVC architecture. Salesforce Object Query Language (SOQL) gives developers an easy and declarative query language that can fetch and process a large amount of data in an easy, human readable query language. SOQL is very similar to SQL used in other database systems and mostly uses similar syntax. Apex and SOQL together give the developers powerful tools for managing the data and processes of their application, leaving the rest of the overage on the Force.com platform. [ 15 ]

Getting Started with Force.com

The following screenshot shows the page editor for Visualforce, it is easy to use and splits a page into two parts, the one at the bottom is for development and the above half shows the output:

Visualforce is an easy to use, yet powerful framework for creating rich user interfaces, thus extending the standard tabs and forms to any kind of interfaces imaginable. Visualforce ultimately renders into HTML and hence we can use any HTML code alongside the Visualforce mark-up to create a powerful and rich UI to manage business applications. Apart from UI, Visualforce provides a very easy and direct access to the server side data and metadata from Apex. The powerful combination of rich UI with access to Salesforce metadata makes Visualforce the ultimate solution for building powerful business applications on Salesforce. As the Salesforce.com Certified Force.com Developer Certification does not include Apex and Visualforce, we won't be going into detail about Apex and Visualforce in this book.

[ 16 ]

Chapter 1

AppExchange

AppExchange is the directory of applications build on the Force.com platform. Developers can choose to submit their developed applications on AppExchange. The applications extend the functionality of Force.com beyond CRM with many ready-made business applications available to download and use.

AppExchange is available at http://appexchange.salesforce.com.

Force.com sites

Force.com is an easier and efficient way to create a public site using the Salesforce. com data, Visualforce, and HTML/CSS. Using Force.com sites we can build sites with functionality in a jiffy. These sites do not requires a login unless it is designed in such a way. Siteforce is a new product from Force.com that helps in creating websites using dragand-drop controls. The sites built using Siteforce do not need any HTML knowledge. The user can directly use readymade components from the directory and create feature-rich websites directly linking their data. [ 17 ]

Getting Started with Force.com

Force.com development

The core process of development involved in traditional software is the same with Force.com. The Force.com platform offers many tools used to define data, business process, logic, and rich UI for the business application. Many of these tools are built-in, point-and-click tools simplified for native users without any development skills. Any user can build applications suitable to their business without a single line of code. The point-and-click tools are easy to use, but they have limitations and control. To extend the platform beyond these limitations, we use Apex and Visualforce. Let us now compare the tools used for traditional software development and Force.com: JAVA

.Net

Force.com

Building the database

Oracle, MS-Access, SQL, or any third-party database setup

Oracle, MSAccess, SQL, or any third-party database setup

Salesforce metadata (and now database.com)

Connection to the database

JDBC

Ado.net

Salesforce metadata API

Developing IDE

NetBeans, Eclipse,and so on

Visual Studio

Online Page Editor and App Setup, Force.com IDE

Controlled environment for development and testing

Local servers, remote test servers

Local servers, remote test servers

Force.com real time sandboxes

Force.com metadata

Everything on Force.com such as data models, objects, forms, tabs, and workflows are defined by metadata. The definitions or metadata are made in XML and can be extracted and imported. The metadata-driven development also helps users with no prior development experience to build business applications without any need to code. We can define the objects, tabs, and forms in the UI using point-and-click. All the changes made to the metadata in App Setup are tracked. Alternatively, the developers can customize every part of Salesforce using XML flies that control the organization's metadata. The files are downloaded using eclipse IDE or Force.com IDE.

[ 18 ]

Chapter 1

To customize metadata on Salesforce UI, go to Setup | App Setup:

As Force.com Developer Certification is about using point-and-click, we will be going into the setup details in the coming chapters.

Metadata API

The metadata API provides easy access to organization data, business logic, and the user interface. We can modify the metadata in a controlled test organization called the sandbox. Finally, the tested changes can be deployed to an enterprise edition or ultimate edition. This ease of access to the organization using metadata API ensures that only debugged and tested code reaches the live organization.

Online page editor and eclipse Force.com IDE Force.com provides a built-in online editor that helps editing the Visualforce pages in real time. The online editor can be enabled by checking the Development Mode checkbox on the user profile, as shown in the following screenshot:

[ 19 ]

Getting Started with Force.com

The online page editor splits the screen into two parts with live code in the bottom half and the final page output in the top half. Force.com also provides an inline editor for editing the Apex code in the browser itself.

Force.com IDE is an IDE built over eclipse. It provides an easy environment to write code and also offline saving too. It also comes with a schema browser and a query generator, which is helpful in generating simple queries (select statements) by selecting fields and object. The code is auto synced with the organization.

Sandbox

Force.com provides a real-time environment to develop, test, and train people in the organization. It is a safe and isolated environment, where any changes made will not affect the production data or application. These sandboxes are used to experiment on new features without disturbing the live production organization. Separation of test and dev instances also ensures that only the tested and verified code reaches the production organization.

[ 20 ]

Chapter 1

There are three types of sandboxes: 1. Configuration-only sandbox: This sandbox creates a copy of the metadata of the production organization. It also copies the reports, dashboards, price-books, and products. The configuration-only sandbox can be used to configure the production organization, create multiple objects and relationships, and deploy them to the production. This type of sandbox does not copy the production organization data apart from the objects mentioned above. 2. Developer sandbox: This environment is specially used for coding and testing of the environment by a single developer. Just like the configuration only sandbox, this also copies the entire customization of the production organization excluding the data. The added feature of a developer sandbox is that it allows Apex and Visualforce coding also.

[ 21 ]

Getting Started with Force.com

3. Full copy sandbox: Full copy sandbox copies the entire production organization and all its data records, documents, and attachments. This is usually used to develop and test a new application until it is ready to be shared with the users. Full copy sandbox has the same IDs of the records as that of production only when it has been freshly created.

Force.com application types

There are some common types of applications that are required to automate an enterprise process. They are as follows: •

Content-centric applications: These applications enable organizations to share and version content across different levels. They consist of file sharing systems, versioning systems, and content management system.



Transaction centric applications: These applications focus on the transaction. They are applications such as banking systems, online payment systems, and so on.



Process centric applications: These applications focus on automating the business process in the organization such as a bug tracking system, procurement process, approval process, and so on. Force.com is suited to building these kinds of applications.



Data centric applications: These applications are built around a powerful database. Many of the organizations use spreadsheets for these applications. Some examples include CRM, HRM, and so on. Force.com is suited to building these kinds of applications.

Developing on the Force.com platform

There are two ways of development on Force.com, one way is using point-and-click without a single line of coding, called the declarative development. The other way is developing application using code, which is called programmatic development. Let us look at the two types of development in detail.

[ 22 ]

Chapter 1

Declarative development

Declarative development is done by point-and-click using a browser. We use ready-to-use components and modify their configuration to build applications. We can add new objects, define their standard views, and create input forms with simple point-and-link with no coding knowledge. The declarative framework allows rapid development and deployment of applications.

The declarative development also follows the MVC architecture in development. The MVC components in declarative development using Force.com are: Model

View

Controller

Objects

Applications

Workflow rules

Fields

Tabs

Validation rules

Relationships

Page layouts

Assignment rules

Record types

[ 23 ]

Getting Started with Force.com

Programmatic development

Programmatic development requires prior coding knowledge. This method allows us to extend the Force.com platform beyond the declarative capabilities. This method gives us control and flexibility over the application we build.

Programmatic development also uses the MVC architecture. Model

View

Controller

Web services API

Visualforce pages

Visualforce controllers

Metadata API

Sites

Apex triggers Web service API

When to use what

The best practice is always to use both declarative and programmatic solutions to build complete applications. Declarative solutions have ease of development and maintenance. They are automatically upgraded with new releases of Salesforce. However, they do not provide complete flexibility to build robust solutions. Programmatic solutions can extend beyond the limitations of a declarative framework. [ 24 ]

Chapter 1

Exercise – creating a developer account

The easiest way to get your hands on Salesforce is to login through a developer account. If you already have one, login to it now or perform the following steps to create one: 1. Go to http://developer.Force.com. 2. Click on Join now. 3. Fill out the form and validate the e-mail address you provided.

[ 25 ]

Getting Started with Force.com

Authentication on Force.com

We can login to Force.com from any standard web browser or third-party application. Force.com uses a three-factor authentication method. From the browser, the user is authenticated using the username, password and the I.P. address of the system. The IP address where the account is created is automatically white-listed for the user.

User name

Password

IP Address

Every time the user logins from a separate IP address, the application verifies the IP by sending an e-mail to the registered e-mail address in the personal profile. Alternatively, the system administrator can enable access by setting the trusted IP ranges. Users login from the white-listed IP ranges are not asked for validation of their IP address or the security token. The Force.com username is in the format of an e-mail [email protected], the username is unique across the global organization of Salesforce. If you already have a developer organization with abc@hotmail. com, you won't be able to create another one in same username. You can give a separate username ([email protected]) and a valid e-mail ([email protected]) in this case.

Exercise – changing your e-mail address Modify your personal e-mail address in the organization as shown in the following screenshot:

[ 26 ]

Chapter 1

To change or modify a personal e-mail address go to Setup | Personal Setup | My Personal Information | Personal Information If you are using your company Salesforce organization, please refer to the e-mail policy of the company before changing the e-mail address.

Exercise – adding trusted IP addresses

To add your IP address in Trusted IP Ranges and white-list it, navigate to Setup | Administration Setup | Security Controls | Network Access as shown in the following screenshot:

If you are within a LAN network of your office, university, and so on, the IP address given by ipconfig command in DOS will give you the internal network specific IP. This IP address is not seen by Force.com; you need the public domain IP address to white-list. To find your public domain IP address, you can visit http://www.whatismyip.com.

[ 27 ]

Getting Started with Force.com

When you login to Force.com from a third-party tool such as Force.com IDE, Outlook Edition, Data Loader, or API you need an additional security token along with a username and password.

User name

Password

Security Token

Every login user gets a security token tied to the password. We need to reset the security token the first time. It is automatically reset whenever password is changed.

Exercise – resetting security tokens Reset your security token in the new org.

To reset your security token navigate to Setup | Personal Setup | Reset My Security Token as shown in the following screenshot and click on Reset Security Token:

Developer.Force.com

Along with a developer account, http://developer.Force.com provides additional resources for developers.

[ 28 ]

Chapter 1

It provides: •

Additional documentation



Online forums



Code share

All these resources can be accessed free with a single developer account. Additional community blogs and resources are available in the final chapter of the book. If you are on Twitter, additional help can be found using hash-tag #AskForce and #AskSalesforce with the Salesforce Community. You may also address the Tweet to @_siddhesh.

[ 29 ]

Getting Started with Force.com

Summary

In this chapter we became familiar with the Force.com platform. We have seen the application life cycle of an application build using Force.com. We saw the multitenant architecture and how it is different from the web-hosting server. We have a fresh new developer account and now in further chapters we will be using it to build an application on Force.com.

Test your knowledge

1. Out of the following things which can be done using the Force.com platform? (Select two) a. Data-warehousing b. Applications with clicks and not code c. Applications can be upgraded without loss of customization d. Code version control system

2. Which of the following statements are true concerning e-mail activation? (Select one) a. The e-mail activation feature requires that the user click an activation link before logging in from a new computer b. The e-mail activation feature cannot be disabled c. The e-mail activation feature can be disabled by request to Salesforce. com support d. The e-mail activation feature can be disabled through the UI 3. A security token is required for API access when connecting from an IP address within the list of trusted networks. a. True b. False

[ 30 ]

Chapter 1

4. Out of the following which applications are suitable for Force.com? (Choose three) a. Time card application b. Word processor c. Online auction management d. Inventory management 5. Which of the following refers to the data model of Salesforce? (Choose 2) a. Force.com API b. Force.com metadata API c. Sandbox d. Force.com IDE 6. What types of paid Salesforce edition are available? a. Enterprise edition b. Unlimited edition c. Trial edition d. Developer edition 7. Where are Force.com IDs identical? a. Production and full copy sandbox only b. Production and dev sandbox only c. Two developer orgs d. Two sandbox org

[ 31 ]

Creating a Database on Force.com Now that we have defined the types of applications that can be built with Force.com and created a developer account we can move deeper into application development. In this chapter we are going to: •

Create objects



Create fields



Create relationships

The exercises covered in the chapter will be useful for you till the time you are working on the Force.com platform. Let's begin...

Library Management System

In the previous chapter we have seen the two types of applications that are suitable for Force.com: •

Data-centric application



Process-centric application

As an exercise in this chapter and for further chapters we will be building a Library Management System. The Library Management System is a data centric application. The processes are built around the central database. Let us take a look at what the customer actually wants.

Creating a Database on Force.com

Requirements

The general public library needs to store information pertaining to its customers, its workers, the physical locations of its branches, and the media stored in those locations. It specializes in lending out two types of media: books and videos. The library must keep track of the attributes of each media item: its location, status, descriptive attributes, and cost for losses and late returns. Books will be identified by their ISBN, and videos by their title and year. In order to allow multiple copies of the same book or video, each media item will have a unique ID number. The following diagram shows a basic E-R diagram for the Library Management System: Video

Customer

Record_id Title Year

Media Record_id

Book

Location Status

Customer_id

BookPenalty

Customer Name Address Phone Number Date of Birth

Record_id

Record_id ISBN Number

CustomerMedia Record_id MediaID CustomerId

[ 34 ]

Fine Amount Customer Name

Chapter 2

The library customers will provide their name, address, phone number, and date of birth when signing up for a library card. They will then be assigned a unique ID number. Checkout operations will require an UID number, as will requests to put media on hold. Each library card will store its own dues. The late fees of returning the media items will be stored in a separate penalty object. These penalties will be summed up for the master object. Employees will work at a specific branch of the library. They receive a pay check, but they can also have library cards, therefore, the same information that is collected about customers should be collected about employees. If you did not understand the problem statement, please go back to the two paragraphs and read it again.

Objects

Force.com is a object-oriented relational database system. An object is the background of any application built on Force.com. The simplest definition of the object is the database table. It is a container to store data on Force.com and also gives you options to create UI for entering, modifying, or deleting records. Force.com doesn't give the option to create database tables using code. For creating a table we need to define the object using the UI. With a new custom object we can directly choose to allow activities to the object or we can choose to add notes and attachments to the object. On choosing these options, Force.com automatically creates the UI for adding activities or adding notes. There are two different types of objects on Force.com: •

Standard objects °°

Standard objects are part of the cloud offering by Salesforce CRM and are much less customizable.

°°

They come packed with some standard properties and functions related to CRM. For example, leads have a lead conversation option. Leads and cases are transferable.

°°

Some standard objects can be renamed, but are otherwise very less customizable. For example, an Account can be relabeled into a Customer.

°°

Standard objects can be enhanced by adding custom fields or modifying the existing picklist values.

[ 35 ]

Creating a Database on Force.com



Custom objects °°

Anything apart from the standard objects is a custom object.

°°

Custom objects have common properties and similar features.

°°

By default, custom objects are given maximum features of the standard objects and can be customized completely.

°°

We can build complete data centric and process centric applications using custom objects.

°°

Custom objects by default contain very limited fields. We have to add more fields according to the requirement.

Let us explore the custom objects in details.

Exercise – creating an object

Please refer to the Requirements section to go through the requirement again. The object structure of the Library Management can be summarized in the following table: Library Management System Object name

Related to (Relationship)

Comments

Media

CustomerMedia (Detail object of Media)

The media object is the master table to store the collection of media. Books and videos are separated by record type to show different types of media.

Customer

CustomerMedia (Detail Object of Customer)

The Customer object stores the customer information. It also stores the total fine paid by the customer as a roll up field.

Book Penalty (Detail object of Member) CustomerMedia

Customer, Media (Master Object)

The CustomerMedia object stores the customer and media in a junction object and is used during the checkout and check-in function of the Library Management.

Book Penalty

Customer

This is a child object on Customer and stores the amount of late fees paid to the customer.

[ 36 ]

Chapter 2

For the purpose of the exercise let us create the Customer object. We have to create all the four objects for the Library Management System, so let us start with the Customer object. The steps for creating a custom object are as follows: 1. Go to Setup | App Setup | Create | Objects. 2. Click on New custom object. 3. Enter the details in the object. The following screenshot shows the custom object field wizard:

[ 37 ]

Creating a Database on Force.com

The wizard consists of the following fields: Field

Description

Label

The label of the object is seen on the user interface. This will be used everywhere on reports, UI pages, and records. For example, Customer and Media.

Plural Label

The plural label is used when we are creating the tab of the object. For Example, Customers, Media.

Starts with a vowel sound

Check if the label should be preceded by "an" instead of "a".

Object Name

This is a unique name used to refer to the object when using the Force. com API, hence it is also called API name. The label is seen on the front-end and the UI of the application while the API name is used to refer to the object from back-end. The Object Name field can contain only underscores and alphanumeric characters. It must be unique, begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores. For Example Customer Note: Force.com automatically appends a __c (double underscore c) to every object name. This is not seen in the UI form but is stored in the database with the name. This is how Force.com distinguishes between standard object and the custom object. The API name of Custom Account object becomes Custom_Account__c.

Description

An optional description of the object. The description saves us from the trouble of remembering why we created the object in the first place when we are viewing the list of all the objects.

ContextSensitive Help Setting

If we are using a custom help for the applications built for the customers, we select the custom help Visualforce page or S-control here.

Record Name

The record name used in page layouts, list views, related lists, and search results. For example, Customer Name or Customer Number or UID. For the purpose of the example, we can name the record name as UID. Note: Irrespective of what the record name is, the API name of the field is always 'name' and is consistent across all standard and custom objects.

Data Type

Data type determines the type of field (text or auto-number) for the record name. An auto-number is a unique number assigned automatically. If the data type is auto-number, it is a read-only field. For the purpose of the exercise we can create the data type as a auto-number. This will be the UID of the media.

[ 38 ]

Chapter 2

Field

Description

Display Format

For a Record Name of type auto-number, enter a display format. The display format can be of the following types: Format Displayed values {0} Incremental single digit values, for example 0, 2, 3 and so on.

{000} Incremental three digit values, for example 000, 002, 003 and so on.

Customer- {00000} Customer - 00003, Customer -123 and so on

UID- {00} {MM} {DD} {YY} UID -02 011410, UID -123 071910

Customer #{0} {MM}-{DD}-{YYYY} Customer #02 01-14-2010, Customer #123 07-19-2010 Starting Number

For a Record Name of type auto-number, this is the starting number from where the counting starts.

Allow Reports

Makes the data in the custom object records available for reporting purposes. We will be discussing reports later in detail.

Allow Activities

Allows users to associate tasks and scheduled calendar events related to the custom object records. The related lists of activities are directly added when this check box is enabled.

Track Field History

This checkbox helps to record the field changes to the object, such as who changed the value of a field, when it was changed, and what the value of the field was before and after the edit. We can easily create audit trail reports when this feature is enabled.

[ 39 ]

Creating a Database on Force.com

Field

Description

Deployment Status

The custom object won't be visible to any users unless it is deployed.

Add Notes & Attachments

Allows users to be able to attach notes and attachments to custom object records. This allows you to attach external documents to any object record, in much the same way that you can add a PDF or photo as an attachment to an e-mail. This option is only available when you are creating a new object.

Launch the New Custom Tab Wizard

Checking this option will launch the custom tab wizard for the object immediately. We will go through this wizard later in this chapter. For now, do not launch the custom tab wizard.

4. Fill the form with the values for the Customer object. Label the object as Customer, the plural is Customers. Fill the other values according to the description. 5. Save the page. We have successfully created the Customer object. A custom object has five default standard fields that store system information. We need to create other fields to store different data in the object. Just like a table in a database an object can have multiple columns, these columns are called fields. Force.com provides some default properties with these fields. Similarly create the other objects for the system. We are going to look at some major types of custom fields on Force.com. Let us create the fields for the Customer object.

Force.com data types

Custom objects include some standard fields that are included automatically. The standard fields include audit fields such as: •

Created By



Last Modified By



Owner



CreatedDate



ModifiedDate

[ 40 ]

Chapter 2

Apart from the owner field all the other fields cannot be edited from the UI. The owner field is automatically assigned to the person who created the record and can be changed by transferring the record to another user. The system fields can be edited only once while transferring the data from full-copy sandbox to the production organization. We will discuss this point later in the Sandbox section.

Custom fields

Force.com provides many unique custom fields types for ease of use and development. The custom fields have unique properties and validation rules with them, so there is no need to add additional validation rules. For example, the Email field comes automatically with e-mail validation, URL field automatically checks if the input is a valid URL, and so on. Once we create a custom field, it can be changed to another type, but if there are records there will be loss of data.

Text fields

Text fields are the basic type of text field. They are free-flowing text fields that can be used to store alphanumeric values.

[ 41 ]

Creating a Database on Force.com

There are four types of text fields: •

Text (maximum 255 characters, single line)



Text area (maximum 255 characters, multiple line)



Long text area (maximum 32,000 characters on multiple lines)



Rich text area (maximum 32,768 characters on multiple lines, accepts rich text formatting also)

Picklists

Picklists are a type of predefined text field. They can be used to prevent spelling mistakes and grammatical errors while entering the data. Picklists are rendered as drop-down picklists on the UI, but it is stored as text in the database. They can store predetermined values like City names, State names, and so on.

Dependent picklist

A dependent picklist is a picklist whose values are filtered by another controlling picklist. The values in a dependent picklist are changed according to the value selected in the controlling picklist. Standard picklists are always controlling fields. Custom picklists can be dependent as well as controlling.

Exercise – creating a dependent picklist

The general library wishes to create categories and sub-categories of books that are available. They first classify the books according to categories of fiction and non-fiction. Fiction books are further classified as children's fiction, fantasy, thriller, and comedy. Non-fiction books are then classified as self-help, management, spiritual, biographies, and inspirational. To create a dependent picklist, we fist create two normal picklists. First create a general picklist of fiction and non-fiction category as seen in the following screenshot:

[ 42 ]

Chapter 2

We create another picklist that has all the values of fiction and non-fiction combined as seen in the figure below:

The steps to create a dependent picklist are as follows: 1. Click on App Setup | Create | Object | Custom Fields and Relationships | Field Dependencies | New. To create a dependent picklist on a standard object click on App Setup | Customize | Object Name | Custom Fields and Relationships | Field Dependencies | New. Most of the chapters in this book are based on custom objects, to customize standard objects go to Customize | Object Name, instead of create.

2. In the Controlling Field drop down, select Categories and in the Dependent field select Sub Categories.

[ 43 ]

Creating a Database on Force.com

3. Click on Continue.

4. The preceding screenshot shows the interface of creating the dependent picklist. On the X-axis we have the Controlling Field values and on the Y-axis, the values of the Dependent Field are spread. 5. To select the values press the Ctrl key and select the dependent values by selecting the corresponding controlling value. °°

Fiction: Children Fiction, Fantasy, Thriller, Comedy

°°

Non-Fiction: Self-help, Management, Spiritual, Biographies, Inspirational

6. Click on Include values. 7. Save the record. If you directly click on Save, the values selected are not saved, so make sure you click on Include values before Save. Alternately you can click on Preview to check if the values you selected have been assigned. This is a good step if you have more values in the controlling picklist.

On the page layout you will see that the Sub Categories checkbox is disabled until you select the categories.

Currency field

This automatically formats the value into currency format. If multi-currency is enabled in your organization, your currency is automatically converted into the corporate currency and displayed on the view. [ 44 ]

Chapter 2

Currency fields are easy to export in Excel as they are directly compatible with Excel currency format.

Other fields

There are some more common fields offered by Force.com such as Phone, E-mail, Checkbox, and so on. These fields are self-explanatory and can be used to improve the data quality. Phone field is the same as number field, but the data inside a phone field is automatically formatted as a phone number.

Field options

Field options are available only on custom fields. Only the picklist values of standard fields can be modified.

Required field

A universally Required field is a custom field whose value is always required whenever a record is saved within Salesforce, the Force.com API, Connect Offline, Connect for Lotus Notes, Connect for Outlook, Salesforce for Outlook, the Self-Service portal, or processes such as Web-to-Lead and Web-to-Case. To create a universally required custom field, check the Always require a value in this field in order to save a record option.

If there is a need to make a particular field required for a particular record-type, do not make it universally required. The field can be set as required from the page layout of the record type. Please refer to the page layout section in Chapter 3, User Interface for more details.

[ 45 ]

Creating a Database on Force.com

The following fields can be made universally required: •

Currency



Date



Date/Time



Email



Master-Detail Relationship (always required)



Number



Percent



Phone



Text



Text Area

Unique field

The custom field can be made unique and case sensitive using this option. Unique fields will automatically get the duplicate check attach while inserting value in them. To set a field as unique, select the Set this field as unique record identifier from external system checkbox as shown in the previous screenshot.

External ID

External ID is the user defined cross-application reference field. If the company is using some legacy system or any other computer system to store data, which is to be synced with Salesforce.com, the primary key in the external system is marked as external ID in Salesforce. The benefits of external ID are: •

The field is auto-indexed, meaning it can be searched from the standard Salesforce search



It is unique



It improves the API SOQL performance



Records can be updated using the external ID (as against Force.com record 'id') to easily integrate with external systems



An object can have up to three external ID fields.



Only a text, number, or an e-mail ID can be marked as an External ID field.

[ 46 ]

Chapter 2

Encrypted field

In case Salesforce org is storing some sensitive information such as credit card numbers, social security numbers, bank account numbers, and so on, we can use the encrypted fields access to Salesforce org. The encrypted fields mask the value of the information with an *. For example, ****-****-****-4321 for a credit card field as shown in the following screenshot:

We can choose the mask type of the encrypted field, as shown in the following screenshot:

Encrypted fields are used to mask the value of the field from users. The only way to see the encrypted fields is by enabling View Encrypted Data permission on the profile. Encrypted fields cannot have default values and cannot be unique or external ID. The encrypted field can be edited irrespective of the View Encrypted Data permission. To prevent people from editing them, we need to use field level security, validation rule, or mark them as read only on the page layout.

[ 47 ]

Creating a Database on Force.com

Encrypted fields are encrypted with 128-bit keys and use the AES (Advanced Encryption Standard) algorithm. They are 175 characters in length unlike the normal text field, which is 255 characters. Due to encryption, there are some limitations on the use of encrypted fields. 1. Encrypted fields are not indexed and hence not searchable. 2. They are not available in filters such as reports, list views, and roll-up summary fields. 3. Encrypted fields cannot be used in where condition in SOQL queries. 4. In an e-mail template encrypted value is always masked, irrespective of View All Data permission. 5. To work with encrypted custom fields, we need to make sure the organization has secure connections using SSL (Secure Sockets Layer) enabled. To enable this setting for your organization, Setup | Security Controls | Session Settings | Require secure connections (HTTPS). 6. If you clone a record that has encrypted custom fields, Salesforce will copy the data from the field only if the user has the View Encrypted Data permission.

Exercise – creating encrypted fields

The general library collects different information about books and videos. Create different fields (as required) to catalogue the information. We will be adding all the fields needed for books and videos in the media object only. In further chapters when we study record types, we will learn how to separate the two types.

To create a field on the object perform the following steps: 1. Go to Setup | Create | Objects. 2. Click on the object you want to create fields on. In this case Media. 3. On the Custom Objects details page click on 'New' custom fields and relationships section. 4. It will open a field creation wizard. Follow the wizard to create the fields. Refer to the E-R diagram and create multiple objects and fields for them. Step 3 and 4 of the field creation wizard can be skipped for now; they will be covered in further chapters. [ 48 ]

Chapter 2

Relationships

We have already discussed Force.com is an object-oriented relational database management system. The backbone of the entire system based on Force.com is in relationships.

Relationships link two different objects with each other. For example, a library user can also be a library card holder. To represent this relationship we need to assign a customer record to a user record, this is achieved using a relationship. There are two main types of relationships:

Lookup (1:n)

The Lookup relationship can be visualized in the following image:

Cards

Lookup CardFines

Fine

Lookup relationships are loosely coupled relationships. For example, a card of a member can have multiple penalties (fines) on it. The penalties on the card are shown at the bottom of the card in a list. Lookup relationships have the following properties: •

The two objects records have no relationship dependencies on each other



The lookup field value is optional



Updating and deleting the child record has no effect on the parent [ 49 ]

Creating a Database on Force.com



Both objects have their own owners and sharing rules



A record can have 25 lookup fields with 25 different objects

Master-Detail relationship (1:n)

The following image illustrates the Master-Detail relationship:

Customer

MasterDetail

Owns

Card

Master-Detail relationships are more tightly coupled relationships. For example, the relationship between the customer and the card in the library management will be Master-Detail. Where the customer is the master and the card is the child in the relationship. Master-Detail relationships have the following properties. •

When two objects are in Master-Detail relationship (also called master-child relationship) the detail/child follows the master.



The ownership of the child record is given to the master objects owner. The child does not have separate owner.



The detail inherits the sharing, security settings as well as the look and feel of the master.



A master record is always required for storing the child record. While creating a Master-Detail relationship, there must be absolutely no record of the object. If there are some records, create a lookup instead. Fill the lookup fields of all the records and then convert it into a Master-Detail.



If the master record is deleted, the child record is also deleted.



In a Master-Detail relationship between a standard object and custom object, the custom object will always be the detail record.

[ 50 ]

Chapter 2



An object can maximum of two master objects. In cases of multiple objects, both the masters are required. If one master is deleted, the child object gets deleted immediately.



A Master-Detail can be multiple level deep, parent-child-grand-children. °°

If the master is standard object: two multiple level deep.

°°

If the master is child object: three multiple level deep.

Special relationships

Using the Master-Detail and lookup relationships we can create two more types of relationships: •



Self-relationship: °°

When an object has a lookup with itself, it is a self-relationship. A self relationship creates a tree diagram of the objects. For example, the account has a lookup on himself, called Parent Account.

°°

On the user object a special self-relationship called the hierarchical relationship helps create superior roles such as supervisor, manager on user object. The hierarchical relationship is a self-relationship of the user object.

Many-to-many relationships: °°

A many-to-many relationship between two objects is a relationship in which an object A can have many child objects B, while object B can have multiple child objects A as shown in the figure below:

[ 51 ]

Creating a Database on Force.com

A real world example is the relationship between student and teacher. A student can be taught by multiple teachers while a teacher can teach multiple students. Normally lookup and master child relationships are 1:N, however, a small trick can create a many-to-many relationship on Force.com. The trick to create the master child object is as follows: •

First create a junction object, which contains a link to two master-objects



Create the name field as auto-number in the junction object

Some properties of the junction objects are as follows. •

The junction object identifies the first master as the primary master. It uses the look and feel of the primary master.



If any master record is deleted, the junction record is automatically deleted.

Exercise – creating a junction object

Create a customer object to collect information about customer. Use the maximum field types described above to create fields. Create a many-to-many relationship between customer and media. This object will be used for checkout and check in of the media item.

Exercise – building the data model for the Library Management System Refer back to the requirements and understand what you have to build. The requirement contains different objects, lookups, master-child relationships, and junction objects. Use the information from the chapter and build the basic data model.

[ 52 ]

Chapter 2

Summary

In this chapter we have studied creation of objects. We created different types of fields to store different types of data; and finally we have started building our first application data model on Force.com, a Library Management System. We have discussed the data types, fields, and the relationship between objects. In the next chapter we will explore creating UI for the objects; we will discuss tabs, page layouts, and Visualforce in brief. We are just warming up, stay alert.

Test your knowledge

1. Which custom fields can be made universally required? a. Formula b. Lookup c. E-mail d. URL

2. Which statements are correct about encrypted fields among the following? a. Encrypted text fields can be an external ID and can have default values b. Encrypted fields are not searchable and cannot be used to define report criteria c. Encrypted fields can be included in search results, and report results d. They are not available for use in filters such as list views, reports, rollup summary fields, and rule filters e. Encrypted fields are not available in lead conversion, workflow rule criteria or formulas, formula fields, outbound messages, default values, and Web-to-Lead and Web-to-Case forms

[ 53 ]

Creating a Database on Force.com

3. A person, who does not have "View Encrypted Data" permission, will see the field with masked characters. Assuming the field is in the page layout, what happens if he clicks the Edit button and tries to edit the value? a. The field will not appear in the edit layout b. The user will see only masked characters, but can enter a new value and save it. c. It will throw an error on changing that field and when he saves d. He can see the original value and he can save it 4. Which is true about encrypted fields? a. They are available in Validation Rules or Apex Scripts even if the user is not having the permission "View Encrypted Data" b. Encrypted fields can be converted to other field types. c. A custom field can be converted to a encrypted field d. In Email Templates, if an encrypted field needs to be displayed without the mask character, the User who receives the e-mail, should have "View Encrypted Data" permission. 5. Which type of custom fields can be used as External Id? a. A text field that is unique b. A text field that is required c. A text field that is encrypted d. Date e. E-mail f. Phone 6. The media object record needs to refer to a similar media object record. For that a lookup field to "media" is created. What is this relation type called? a. Master-Detail b. Lookup c. Hierarchical d. Many-Many e. Self

[ 54 ]

Chapter 2

7. How many master relationships can be there per detail object? a. 1 b. 2 c. 3 d. 4 e. 5 8. How many lookup relationships can be there per child? a. 10 b. 20 c. 15 d. 25 9. A Standard object has more than one Master-Detail relationship? a. True b. False 10. How do you create many–to-many relationships? a. Junction object (custom object) having a Master-Detail to the other two objects b. Create a lookup on the first object for the other and lookup on the second for the first

[ 55 ]

User Interface In the previous chapter we saw the object database behind Force.com. A robust system is one that separates the view from the model. In the model, we have now created objects and created relationships between the objects. The objects that we created in the last chapter need an equally rich UI for users to fill data. They need placeholders and visual indicators to collect this data and the information. As with the tradition of Force.com, most of the things are point-and-click. Similarly, in this chapter we will be using point-and-click controls to create some important page layouts and UI designs. By the end of this chapter, you will be able to: • • • • • •

Build an application Create tabs Create forms Create page layouts Understand the importance of a Visualforce page Create a basic Visualforce page

The Salesforce Developer Certification requires us to have an overview of Apex and Visualforce; hence we will be covering only the basics of the Visualforce in this chapter and the basics of Apex in the next. So let's start creating some amazing user interfaces...

What is an application?

An application or an app is a collection of tabs and objects used together to form a business process. Different tabs and objects are grouped together to form a single business unit for user convenience.

User Interface

The following screenshot indicates the standard application provided by Salesforce. com by default:

Salesforce provides standard applications such as Sales, Call Center, Marketing, Community, and Force.com.

Understanding a custom application

We can customize an application by giving it a custom logo, a custom name, a custom description, and a custom landing page. We can give the instructions to use the objects on the custom landing page.

All custom applications display the standard Salesforce logo. The logo can be replaced with a custom logo. The custom logo can be any GIF and JPG file from the Documents tab.

[ 58 ]

Chapter 3

Unlike other images, the custom logo should be placed under the Documents tab and not static resources. Image dimensions should be a maximum of 300 pixels wide by 55 pixels high and 20 kb in size.

We add the tabs that should be included in the application, for example, in the application of library management we include tabs, media, customer and so on. The default landing tab can be selected here on the screen. The last step of the application creation wizard is assigning the profiles to the application; we will discuss this later.

Exercise – building your own application

Let's continue building the Library Management System. Build an application for the Library Management System. Design a simple custom logo for the same. To build your own application perform the following steps: 1. Go to User Name | App Setup | Create | Apps. 2. Click on the New button to start the wizard. 3. In the first page of wizard give a proper name to the application as shown in the next screenshot and click on Next.

[ 59 ]

User Interface

4. Select the appropriate logo for the application, the Salesforce latest addition logo will be available by default as shown in the next screenshot and click on Next. The logo should be already present in the Documents tab at this stage.

5. On the next page, it will ask for the tabs to included in this application. We will be looking at custom tabs in the next section, for now keep the third page blank, but make a note, as once we learn about custom tabs, we will return to select the appropriate tabs. 6. Skip the next step too for now, we will be covering profiles in Chapter 7, Application Administration. Click on Save.

Custom tabs

A custom tab is used to display object data or other contents embedded in the application. The custom tab has a unique tab style. We can choose the color and icon for the tab.

[ 60 ]

Chapter 3

The following screenshot shows the different types of tabs:

We cannot create tabs for standard objects. The Standard Object Tabs can be hidden/ shown and added to any custom application. There are three types of custom tabs: •

Custom Object Tabs: °°

These tabs display the custom object data.

°°

They provide the options to create, read, update, and delete (also called CRUD rights) an object.

°°

The plural name of the object is given to the tab by default.

°°

The buttons of respective operations are visible depending on the user rights of the object. We will be studying user settings in Chapter 7, Application Administration. [ 61 ]

User Interface





Web tabs: °°

We can display any external website using the web tab.

°°

The web tab is useful if we want to show the external web-based applications (for example, Google, Evernote) inside Salesforce.

Visualforce tabs: °°

Tabs can also be made in rich UI and complex coding using Visualforce and HTML.

Exercise – creating custom tabs

In the Library Management System, we have so far created different objects to collect data on media and customers. The general library wants to collect people's information using the web interface. They require tabs to store this information. Create object tabs for all the objects created in Chapter 2, Creating a Database on Force. com. To create a custom object tab follow the instructions: 1. Go to Username | Setup | App Setup | Create | Tabs. 2. Click on New in the Custom Object Tab section to open the New Custom Object Tab wizard as shown in the following screenshot:

[ 62 ]

Chapter 3

3. We can choose the color combination and icon for the tab in the Tab Style field. Click on Next. 4. Skip the next step and directly jump to Next. 5. Select the applications this tab should be included in. For the exercise, select only the Library Management Application and click on Save.

Page layouts

Page layouts are needed to display the data collected in the system. Most of the page layouts are highly customizable while others are very poorly customizable. Page layouts can also be assigned to particular users or a type of record that is Internet. We will be looking into record type and page layout in Chapter 4, Implementing Business Logic. Every object on Force.com has a minimum of three separate page layouts: •

List view /tab view: °°

The list view of objects is the first view a user sees. When we click on the tab of the object we see the list view of that object.

°°

The following screenshot shows the list view layout of the opportunity object:

°°

Force.com allows very minimum configuration of the list view. We can select the fields that are seen on the list view. The list view is also seen on the related list of the object. [ 63 ]

User Interface



Detail view: °°

A detail view shows the detail of a single record. To enter the detail view we can either click on the record name or we can directly append the record ID in the URL. For example, http://na1.salesforce.com/RecordID. The URL can be different for different instances of Salesforce. For the complete list of Salesforce URLs please visit http://trust.salesforce.cm.

°°

The detail view is fully customizable for any standard and custom object except for a few special objects. The following is the detail page for sample records:

We will be looking into the layout editor in detail in the coming chapter. •

Edit view: °°

The edit view also focuses on the single record, but this provides input fields to enter and modify the records.

°°

The following screenshot is of the edit view for the same opportunity:

[ 64 ]

Chapter 3

°°

The edit view follows the pattern of detail view and only those fields are shown in this view, which is editable. The edit view cannot be customized differently to that of the detail view.

Page layout editor

The page layout editor is used in the organization of the Fields, Custom S-Controls, and Related Lists on a detail page layout. The fields that are editable are automatically available in the edit page layout.

Using the page layout editor

To open the page layout editor go to Setup | Create | Objects | Custom Object name | Page Layouts. As mentioned in the previous chapter, alternatively for a standard object go to Setup | Customize | Object Name | Page Layouts.

[ 65 ]

User Interface

Normally, every object will be assigned a single default page layout that is accessible to all the people. Some standard objects have multiple page layouts. To modify a page layout make sure you identify which profile the page layout is accessible to prevent data visibility problems. The following screenshot shows the enhanced page layout editor:

[ 66 ]

Chapter 3

Some salient features of the editor are as follows: 1

We can select other layouts to edit quickly.

2

The modified layout can also be saved in a different name.

3

We can select between Fields, Buttons, and Related Lists.

4

With the layout properties, we can change the name of the layout and make it user friendly and understandable.

5

Fields, buttons and layouts are available for adding on the page. Already used objects are disabled.

6

The highlights are used for consoles we will discuss this later in further chapters.

7

Buttons can be added only in the custom buttons slot and are not available on the edit page layout.

8

Lock indicates the field is locked from being removed on the page layout. These fields cannot be removed from a page layout.

9

Fields can be organized and grouped together in sections. A section can have a single column or a double column.

10

We can add custom links to the records in this part of the page layout.

11

Related lists are added only in the records having a lookup relationship and a master detail relationship with other objects.

12

Additional properties on the related list can be edited by clicking on the wrench symbol. We can add/ remove fields from the child object to be displayed on the page of the master object using this.

Sections and blank spaces

Apart from adding the fields and buttons, the advance page layout editor also helps us group different fields in sections and add blank spaces for alignment. The following screenshot shows the Section and Blank Space in the editor:

[ 67 ]

User Interface

Let us the look into these two options one after another: •

Adding a section: A section is a logical grouping of fields on a page. It is always advisable to group the fields in a user friendly pattern so that the user finds it comfortable to edit the record. The following screenshot shows the Section Properties dialogue box:

A section can have a single column or two-column layout. We also get the option for the Tab-Key Order in a section. •

Blank Space: A blank space can be added to align the fields properly in the section. This is in case we need to add a blank space intentionally on the page layout.

Exercise – creating page layouts with the cloud based editor

The general library is filling information in the Media object that we have created previously. However, the fields are spread across the page and the users are finding it difficult to fill in the information. Group the fields in a logical grouping on the page layout editor. Some fields are different for books and videos. Create two separate layouts, one for books (with ISBN number) and one for videos (with title and year).

[ 68 ]

Chapter 3

Custom buttons and links

We can add the custom buttons and links to the record. Buttons and links have actions attached to them referring to the functionality they are achieving. For example, a Save button saves the data filled in the application to the server. The buttons are also differentiated based on their placement on the application. There are three types of buttons available: •



Detail Page Link: °°

This is a link that is added to the page layout within the Custom Links Section as shown in the following screenshot:

°°

The Custom Links Section can be adjusted anywhere on the page. However, any Detail Page Link that is created is added only in this section.

Detail Page Buttons: °°

The Detail Page Buttons are added at the top and bottom of the page in the centre as shown in the following screenshot:

[ 69 ]

User Interface

°°



The button can open a JavaScript, point to a Visualforce or open a URL. There is a separate section for adding this button on the page layout editor as shown in the following screenshot:

List View Button: °°

The List View Button can be added to the tab page or the related list of the object. The following screenshot shows the list view button on the related list for opportunity. The list view button is the only type that can be added to the related list of the object and not on the detail page layout.

Buttons cannot be added on the edit page of the record. Page layouts for the user object only include Custom Fields, Custom Links, and Visualforce pages. Tagging, Related Lists, Custom Buttons, and Standard Field customizations are not available.

Creating a custom button or link

To create a new button, perform the following steps: 1. Go to Setup | Custom Object Name | Custom Buttons and Links | New as shown in the following screenshot:

[ 70 ]

Chapter 3

2. Choose the type of button (Detail, List View or Detail page link). 3. Choose the behavior of the opening page. 4. Choose the type of button (Visualforce page, JavaScript, and so on). 5. Save the custom button. After we create the button we again go back to the advance page layout editor to add the button on the page.

[ 71 ]

User Interface

Field options

When we are adding fields on the page layout they can be made Required or Read-Only by setting their properties. The Field Properties dialogue box shown in the next screenshot can be accessed by clicking the wrench symbol on the desired field:

As shown in the screenshot we can set the field to be Required or Read-Only on the page layout. As mentioned in the previous chapter, if the field is not universally required (set as required during the creation of the field) it can be made required on the page layout. It should, however, be noted here that the field marked as required here will be required only on this page layout, it will not be required if the data is filled from the back-end or through API or any other page layout. This option is useful if we have a single page layout that requires this field.

We can also set the field as read-only in the same option, the field appears uneditable on the page only and the user can still fill the value from other page layouts or the back-end.

Editing other layouts

The advanced page layout editor only helps in editing the detail page of the record. Force.com does not allow us to modify the edit page for the record. Edit page layout assumes the same pattern as the detail page layout only the editable fields are displayed with a Save button.

[ 72 ]

Chapter 3

Apart from that Force.com gives us the option to modify other layout such as the lookup layout (choosing which fields to show when lookup for the object is clicked) or the tab layout. Let's edit the Media Lookup layout as an example: 1. Click on Setup | Create | Media | Search Layouts as shown in the following screenshot:

2. Click on Edit on the Lookup Dialogs, a dialogue box similar to the one shown in the following screenshot should appear:

3. Select the fields that will appear on the Lookup Dialogs. For example, select the Not Available field and click on Add. 4. Click on Save to save the record. 5. Now every time there is a lookup on media object, it will show the Not Available field in it. [ 73 ]

User Interface

We can add a custom list button to the search results and media list view. On the other layout, we can only select which fields are to be displayed on screen. To add a button to the landing tab, we will add a custom Visualforce button on the list view, and to customize the columns they can be done using the tab of the object.

Similarly we can customize the other layouts for the object too.

Mini page layout

We can define mini page layouts for the records that appear in the mini view of the Console tab, hover details, and event overlays. A Mini Page Layout contains a subset of the items in an existing page layout. Mini page layouts inherit record type and profile associations, related lists, fields, and field access settings from their associated page layout. The visible fields and related lists of the Mini Page Layout can be further customized, but the other items inherited from the associated page layout cannot be changed on the Mini Page Layout itself. To create a Mini Page Layout, click on Setup | Create | Object Name | Page Layout. Click on Mini Page Layout on the green bar on top.

[ 74 ]

Chapter 3

Just like Search Layout, the Mini Page Layout, and the mini console layout gives us the option of the field names that can be added to the layout. This completes the page layouts and the visual point and click features of Force.com. The Salesforce Certified Developer program gives an overview of what Visualforce can offer and the basic tags used in it. The following section will give a brief overview of Visualforce, we won't be going deep into coding. Let's start with it.

Overview of Visualforce

Visualforce is a markup language that uses syntax similar to HTML and XML, to easily create rich-interfaces. The UI designed by Visualforce is feature rich and can be used to make pages compatible with multiple mobile devices and browsers. Visualforce uses XML-like syntax at the front-end to design pages and APEX as a back-end to implement business logic.

Visualforce content

A Visualforce page is finally rendered into HTML, so a Visualforce page can be a combination of Visualforce tags, HTML, and JavaScript. Any other code that requires HTML and JavaScript can be used inside Visualforce, such as an embed tag for flash. We can create a Visualforce page up to 15 Mb, however, it is recommended to keep pages as small as possible. Visualforce understands the underlying meta data component of Salesforce. It automatically replicates the properties of the fields in the database. For example: •

If a field is required, it is marked with a 'red' marker automatically



A date field has a calendar picker

Visualforce components directly create the Salesforce look and feel, with no additional CSS or HTML requirement. Visualforce pages are automatically upgraded to the next release, if the Salesforce UI changes in the release, Visualforce UI automatically changes. It separates the view from the data model and the business logic, helping to create rich UI-based pages. [ 75 ]

User Interface

Key components of Visualforce

Visualforce pages have some unique components that make them easy to build and use with the Force.com platform.

Pages

Pages are used to create feature rich user interfaces for Force.com. They use standard web technologies such as HTML, JavaScript, and CSS. Pages are composed on the server and not the client

Standard components

Salesforce by default provides more than 60 standard UI components. Every UI feature provides a standard out-of-the-box feature. For example, a date field component comes with a standard date picker, and page block table automatically assigns a CSS. We can create a complete detail page using a single tag. The components have built-in Ajax functionality to partially refresh page. A full list of components is available at: http://www.salesforce.com/us/developer/docs/ pages/index_Left.htm#CSHID=pages_compref.htm

Controllers

Force.com provides us with standard controllers that help us re-use standard functions such as save, delete, and so on. A standard controller has access to the Salesforce database. It automatically adjusts to the type of page based on where it is called. For example, an input field will work as a new field for a normal page and edit field if the page is called with ID as a parameter. There are two types of Salesforce controllers.

Standard controllers

Standard controllers are available for all standard and custom objects. They provide standard functions such as save, delete and create records. Standard controllers are added to a Visualforce page using the following syntax:

[ 76 ]

Chapter 3

As previously mentioned Salesforce appends __c to the object API name in case of a custom object. To refer to the standard controller of the custom object don't forget to append the __c to the API name.

Standard controllers are very helpful in designing a custom UI for custom pages. We can create a complete page with much less effort using standard components and controllers. We get standard controllers even for custom objects. Standard controllers are available for all those objects created on Force. com. Some standard objects do not have standard controllers, these are usually the objects that are hidden or do not have any page layout or tabs.

For example, if we create a page to input a record through user fields, if the page is called without an ID it renders as a new record creation page, however, if we pass a record ID as a URL parameter, the page automatically renders itself as a edit page for the record.

Custom controllers

Custom controllers are written in Apex code and are used when we need to write functionality other than the standard functionality. Custom controllers are used to create wizards, rich UI with complex data sets, and so on. Custom controllers are added to the Visualforce page using the following syntax:

Here CustomApexClass is an Apex class that controls the Visualforce actions and variables.

Controller extensions

Controller extensions give the benefit of standard controllers as well as custom controllers. We can use the ease of standard controllers with the flexibility of the custom controllers in a single page. Controller extensions are used when we are building a Visualforce page to override a standard link or a button. Controller extensions are called using the following syntax:

[ 77 ]

User Interface

In the given example, opportunity is a Salesforce object while CustomApexClass and SecondCustomApexClass are Apex class. We can add multiple extensions on a Visualforce page using a comma separated value.

Standard list controller •

To override the buttons or add custom buttons on the section of related lists or tabs we create standard list controller. Both the tab and related list layouts are list views, which display rows of data with checkbox.



To create a standard list controller we add the attribute recordSetVar to the header. For example,

The recordSetVar attribute is used to create a variable on the Visualforce page that can store and iterate on a list of objects. A standard list controller comes inbuilt with pagination and navigation.

Data binding in Visualforce

We can bind Apex and data components in Visualforce using the expressions. The expressions used in Visualforce are similar to formula fields, workflow rules, and so on. The syntax for binding data on Visualforce is: {!Some_expression_or_data}

Context variables are shown using a prefix $ before them. For example, the login user username can be referred to as: {!$User.username}

The context variables are used to refer to the current context of the user and the organization.

[ 78 ]

Chapter 3

Using the Visualforce pages in the organization

Visualforce pages can be used in two different ways in the standard organization: •



Buttons and links: °°

A Visualforce page can be called using a custom link to the Visualforce unique URL (Salesforce_server_url.salesforce. com/apex/VisualforcePage)

°°

A Visualforce page can be used by overriding the standard button

°°

Creating custom buttons to open the Visualforce page

°°

Creating a JavaScript button to open the Visualforce page

°°

A Visualforce page can be called using the custom help link for the custom object

Page layouts: °°

A Visualforce page can be added as a custom tab to the application

°°

A Visualforce page can be used by overriding the tab overview

°°

A Visualforce page can be embedded into page layouts

°°

A Visualforce page can be added into dashboard

Visualforce tags

Visualforce has a common tag library, which provides rich content and components to embed Salesforce data and logic seamlessly in a page. The tags are similar to HTML and are easy to use. The layout HTML tags such as , , and

can also be used on a Visualforce page, however, it is advisable to use the Visualforce counterpart for the same for better usage and smoother operations. , , and tags are to be avoided at all cost. These tags won't throw a compilation error, but there is no use including them as they are already included before the Visualforce page is rendered.

[ 79 ]

User Interface

Visualforce tags must be well-formed. Every opening tag should have a matching closing tag. Nested tags should be closed in the reserved order as they are opened. For example:



All Visualforce tags have the apex: prefix. is the topmost parent tag in a Visualforce page. The following screenshot shows a basic Visualforce page:

Binding tags with data and Apex

Visualforce tags are basic components to create view of the application. They interact with the model and the controller using bindings.

[ 80 ]

Chapter 3

There are two types of bindings for Visualforce tags: •

Data bindings: °°

Dynamic object data can be inserted into the Visualforce page using the following syntax:



{!ObjectApiName.FieldApiName}



For example., {!Media__c.name} °°

Global data such as login user, company information, and so on can be bound to the page using the $ syntax

°°

Custom labels can be accessed using $Label syntax, such as {!$Label.LabelName}

°° •

For example, the {!$User.firstName} gives the first name of login user first name

Action bindings: °°

To trigger events, such as entering into a text box or pressing a button, we bind the action to the component

°°

The methods can be standard methods provided by Force.com such as save, delete, or they can be custom methods written in Apex controllers

Visualforce component library

As we have seen before Visualforce provides us with standard components to simplify the task of creating visual elements. These components come with some inbuilt functionality such as validation check or AJAX rendering. Using these components reduces the efforts of developing the code for them. In this section we will be going with the basic components used in Visualforce. The Component Reference is the best place to explore different components and their use.

[ 81 ]

User Interface

As shown in the following screenshot, the Component Reference is located in the top right hand corner of the Visualforce page editor:

Layout components

Layout components are used to create the page layouts and the structure of the page. They are responsible for the styling, the layout, and the visual elements of the page. •

: It is the basic component of any Visualforce page. It is the markup at the beginning of the page and also the ending markup of the page. All other tags are enclosed within the markup. The following are the most important attributes of the tag:

°°

StandardController or Controller or Extensions: If we are

°°

For using the custom controller, we use the Controller attribute.

°°

Title: Title of the page after it is rendered. The title renders to the

°°

TabStyle: We can choose the style-sheet of the tabs already in

using the standard object controller we add the object name to the standardController. We can also add custom functionality to standardController using extensions.

title HTML mark-up.

Salesforce.

[ 82 ]

Chapter 3

If we use the standardController it automatically inherits the tab coloring of the object, so there is no need to add the tabStyle. tabStyle is needed when we are using a custom controller to add a complex functionality to the standard object to give the end-users a similar look and feel of the application.



°°

Action: Action attribute refers to the action method to be invoked

°°

Sidebar: A Boolean value that indicates whether to show/hide the Force.com sidebar on the page.

°°

ShowHeader: A Boolean value that indicates whether show/hide the

°°

RenderAs: RenderAs gives us the option to generate a PDF from the Visualforce page.

on certain event. On page the action method is invoked during the pageLoad event.

header and the tabs of Force.com.

: Other related components are used to mimic the Salesforce default stylesheet. When nested within each other correctly they create the exact Salesforce look and feel for the page. The following figure illustrates the use of pageBlock components to generate the Salesforce look and feel.

[ 83 ]

User Interface

component has a few nested components as follows:

°°

: Used to add buttons on the page. This markup creates a button on the top and the bottom of the section just like Salesforce. Alternatively, we can specify the position of the buttons using the position attribute.

°°

: A section is used to group number of fields together for ease of operation.

°°

: When we include a input field inside the pageBlockSection, Visualforce automatically renders it along with

its label. Any property associated with the field, such as a required field, date picker is also rendered automatically. °°

: PageBlockSectionItem helps in aligning a custom field with its label. When we use any other input field like or the fields are not automatically formatted according to the layout. In that case we wrap them around with the . The tag can have only two nested tags inside it, one for the label and another for the input field. This helps us in mapping it to the standard UI of Salesforce.

Other layout components

We discussed the basic layout components that help us style the page according to Salesforce stylesheet; apart from these Force.com provides some other components to set the layout. Let's quickly look at some of these components. °°

: It helps in creating a toolbar with a clickable item. The toolbar can be given a custom look and feel using custom CSS.

We can group items using the component.

Neither tab panel nor tab can help us create a top-level tab. We have to use the tab creation wizard for that. Refer to the first half of this chapter for details.

°°

: It is used to create a custom tab panel with different content. The tabs created using this component are different than the Salesforce tabs, but work just like them. Tabs are created using .

[ 84 ]

Chapter 3

Standard Salesforce components

To easily create Salesforce pages, Force.com provides us some standard components that mimic the Salesforce standard page. These components are very easy to use. However, they offer much less flexibility in terms of customization. •



: This component creates the detail page layout for the object. The record ID should be provided in the Subject attribute. Optionally, we can choose if relatedList and relatedListHover should be added to the

page layout using the respective Boolean values. : This component is helpful in creating the related list record for the parent record. Alternatively, we can specify which child relationship to be displayed using the list attribute. Just like apex:detail we have to specify the record ID using the subject attribute. We can specify the number of records to display using the pageSize attribute.

Data components

To display a large chunk of data on a Visualforce page we use the data components. • •

: It creates an ordered or unordered list of data. This is a single column list and cannot show a complex matrix. : It creates a matrix of data in HTML table format. We can customize the columns and rows of the table. A data table does not apply any style to the displayed data, to apply style we need to use the the attributes and function of both are similar.

Output components

Output components are used to display some output text or data from the object. All the output components are uneditable, they can be nested inside the dataTable mentioned above. •

• • •

: It is a component that displays the record field in the

label-value format. If the page is composed using the Salesforce stylesheet, it automatically adds the field label and the value to the data displayed. If the data displayed is not from Salesforce records, we use output label to label the record. : It creates an anchor HTML tag and can be used to link other pages or URL. : It is used to display a static or dynamic series of text. [ 85 ]

User Interface

Input components

The is directly bound with the Salesforce object properties. The field name is specified in the value attribute and the respective UI are automatically rendered on page, for example, date picker for date field, red marker for required fields as shown in the following screenshot:

Alternatively, we can use the required attribute to make it mandatory to fill the field.

If the field is universally required and this attribute is set to false, the field will not show the red marker on the page. However, there will be an exception as soon as we try to save the record. It is advisable not to make the universally required fields as unrequired using the attribute.

To display the field label along with the input box, we have to nest it inside the markup. Apart from the input field Force.com also provides us with some other input components that can be used for collecting multiple uses. The following screenshot shows some of the components in action: [ 86 ]

Chapter 3

Some basic input components are as follows: • •

: It is a checkbox that is used to collect Boolean input. : It renders into a hidden field, useful in storing

• •

: It acts like a simple text box with no formatting at all. : It is a larger text box used to store information. Alternatively, we can use RichText=true to use a basic formatted input. : It is a markup used to create a basic file upload



• •

variables for passing between pages.

functionality. Files can be uploaded as attachment on records or in documents. : It is a component useful in creating password fields on the Visualforce page. and are used to create buttons and links respectively that perform some server side action. The action is specified using the attribute action and may refer to standard actions such as, {!save}, {!delete}, and {!edit} or some custom Apex Method written in the supporting controller. [ 87 ]

User Interface

AJAX and JavaScript in Visualforce

Visualforce is directly compatible with JavaScript. We can use external third-party codes and script like YUI or jQuery directly into a Visualforce page. Visualforce provides us with standard AJAX-based components. We can render a small section of the page instead of rendering the entire page, thus creating a rich UI experience. We will be discussing a few AJAX components below.

AJAX components

In AJAX format, instead of sending the complete page to the server, a partial page is sent and the response is modified on the page immediately without refreshing it. The following screenshot shows the AJAX in use while filling a simple e-mail form:

Visualforce provides us with easy to use AJAX components to achieve this. The following is a basic overview of the AJAX-based components in Visualforce: •

• • • •

area is marked for AJAX processing. Without using actionRegion the entire page is send for processing, but with actionRegion

only the page inside the block is refreshed. : It is used to invoke the Apex classes from JavaScript. : As the name suggests, actionSupport adds an AJAX service to other components allowing them to partially request. : It can poll the AJAX request to occur after a particular countdown. : It displays the status of an AJAX update.

This is just an overview of the components in a Visualforce page, for more detailed explanation and sample code, please visit the Component Reference Library. [ 88 ]

Chapter 3

Inline Visualforce on page layouts

We can add inline Visualforce directly inside a page layout to add rich features to the page. The inline Visualforce page has to be a standard controller page or a controller extension. The following screenshot shows the Google Map visualization of account address using an Inline Visualforce page:

The Inline Visualforce page can only be added on the detail page of the layout and not on the edit page, so if there are any editing fields to be added they get added on the detail page. The Inline Visualforce page has a separate space for buttons; hence the buttons do not show along with the normal Salesforce buttons, but separately. To add an Inline Visualforce page simply drag the desired page on the page layout as shown in the following screenshot:

[ 89 ]

User Interface

As the Visualforce page gets added in the middle of the page layout it is advisable to remove the headers and the sidebars for the new Visualforce page.

Static resources

Static resources allow you to upload content that you can reference in a Visualforce page, including archives (such as .zip and .jar files), images, stylesheets, JavaScript, and other files. We can package a collection of related files into a directory hierarchy and upload that hierarchy as a .zip or .jar archive. We can reference a static resource by name in page markup by using the $Resource global variable instead of hard-coding document IDs. We can store CSS, JavaScript, and other supporting files in static resource. To create a new Static Resource navigate to Setup | Develop | Static Resource | New.

Summary

In this chapter we explored the view capability of Salesforce.com. We learned how to create tabs and page layouts. We saw the advance page layout editor and its use in creating pages. This chapter also gave an overview of Visualforce and we saw some basic tags used in creating pages. In the coming chapters we will be exploring how to show a different page layout for different login names or data types. We will be revisiting these lessons after we see the roles and profiles part. Now we can create the application with complete page layouts and the tabs for users to enter data, in further chapters we will be exploring the logic as a service provided by Salesforce.

[ 90 ]

Chapter 3

Test your knowledge

1. Which of the following statements are true about page layouts? a. b. c. d. e.

They can have one or two columns per section We can add a list button using a page layout editor We can hide a section header detail view or edit view or both view We can add blank spaces instead of fields Preview the layout for different profiles

2. In a Model View Controller architecture, which of the below corresponds to View? (Select two) a. Page layouts b. Validation rules c. Tabs d. Workflows 3. What is possible through page layouts of custom objects? (Select two) a. Add custom fields and buttons b. Set mandatory field based on certain value on other field c. Add inline visual force pages d. Set three column display 4. Of the following, what are the things not possible to include in the user page layout (Choose two) a. Tagging b. Custom links c. Inline Visualforce page d. Custom buttons e. Custom fields 5. Which of the following refers to the controller part of the MVC architecture? a. Apex b. Visualforce c. S-control d. Page layout

[ 91 ]

User Interface

6. Which editions support Apex and Visualforce? (Select two) a. Unlimited Edition b. Enterprise Edition c. Apex Edition d. Professional Edition e. Group Edition 7. Position is a custom object containing details of each position. Candidate contains the details of each candidate such as skills. When a user is viewing the position records, he should also be able to see all those candidates who match the skill required for the post. However, a position can have no candidate and a candidate record can also be kept blank. A position can be applied by multiple candidates, while a candidate can also apply to multiple positions. What can be done to achieve this? a. Create a master-child relationship between them b. Create a junction object to store both the values c. Create a lookup relationship of candidate on position d. Create a Visualforce page 8. The user wishes to add the ratings on the page. The ratings will be displayed as the radio button from 1 to 5 with the features on the y axis. How can we achieve this? a. Create a new field radio button b. Create a picklist with radio values c. Create a Visualforce page to include radio group in a data table 9. What are the different custom tabs that you can create? Please select three choices. a. Web tab b. Apex tab c. Visualforce tab d. Custom object tab e. Standard object tab

[ 92 ]

Implementing Business Logic In the last few chapters, we started with the basics of Force.com. We saw how to create database objects, we created page layouts and tabs. Business logic is the brain of the application; it make sense of the data and also responds to the button clicks of UI. With Force.com providing an easy way to handle the data and the visual UI, the developers can focus most of their energy and time in developing amazing business logic. As always, Force.com provides us with easy-to-use, point-and click-options to develop business logic. In this chapter, we connect the data to the view using the controller. We will be seeing: •

Logic as a service



Formulae



Validation rules



Assignment rules



Workflows



Approval process

As mentioned in the previous chapter, we won't be covering Apex in detail, but only giving an overview. Let's start creating some robust business logic for the application.

The basic rules of implementing business logic

Force.com provides some basic controls for the validation of data, automating a process, triggering an e-mail alert after a particular duration, and auditing and tracking important fields such as status, and so on.

Implementing Business Logic

Rule syntax

Force.com provides us with two ways of creating a rule; the simplest way is setting the fields to values, for example, Field X equals value Y or Field A does not equal value B as shown in the following screenshot:

We can also write complex rules using formulae, which offer flexibility to use advance logic such as AND, OR, IF, and so on. The following screenshot shows the setting up of the validation rules:

[ 94 ]

Chapter 4

There are different types of rules used in different areas. They are as follows: •





Validation rules: Validation rules are used to validate the data populated in the field of a record. They can be used to provide a user-friendly error message in case of data discrepancy. For example, to check if the discount is not greater than 35 percent. Workflow rules: Workflow rules are used to automate a process that is usually done manually. They can trigger an action when the rule is set true. For example, setting the checkbox to true if the value of X is Y. Approval process entry rules: The rules here ensure that only a particular set of records enter this approval step. For example, if the amount is greater than 50,000 it should only go to the head of the finance department for approval.

The rules that are used in any of the above have a common syntax. A rule syntax consists of the following components: • •

• •

Literal value: A literal value can be any string or a numeric component. For example, 0 in the above formula. Field values: These are references to the existing fields on the object. For standard fields we use the API name as the reference, for custom fields we append a __c to the API name. Global values: These refer to the value of a system or environment variable, such as information about the logged in user or the organization settings. Function and operators: Force.com provides us with functions to operate on the data. There are different sets of functions provided by Force.com for different sets of operations. Please refer to the cheat sheet of Force.com formulae for the different functions and operators provided by Force.com. http://media.developerforce.com/cheatsheets/ SF_formulas_developer_cs-2Pg_HR.pdf

Validation rules

Validation rules are attached to fields. They are executed when a record is created or updated. We define the validation rule and the condition for execution of the rule along with an error message. If the evaluation of error condition results in a true value, the record is not saved, and the error message is generated. When we create a general field, some validation rules are set by default due to the property of the field, for example, an E-mail field checks for the pattern of @ and . (dot) in the entered string, the number field checks for numbers entered in the string. [ 95 ]

Implementing Business Logic

For custom validations, we use validation rules. Validation rules are permanently bound by the field and are universal. Every time the field is inserted it validates the field value with the validation rule. For example, the following validation rule checks for the Social Security Number of the customer and throws an error if it is incorrect.

Validation rules are used to preserve the data quality of the data. We can use validation rules to prevent data loss in the record. We can use the formula isChange to determine if the value in a certain field is changed and the user profile.

[ 96 ]

Chapter 4

Exercise – creating a validation rule

The general library wishes to store the social security number and a valid credit card number for the subscription. How do they ensure that the right pattern is entered in the respective fields? To create a validation rule perform the following steps: 1. Navigate to Setup | Objects | Validation Rules | New as shown in the following screenshot:

2. Add a user-friendly Rule Name to identify the rule in the first section. 3. In the second section on the right hand side we see the list of all the Functions available to create the formula.

[ 97 ]

Implementing Business Logic

The formula uses basic functions, which are provided by Salesforce. com. These functions are similar to the Excel-based functions. For a complete list of functions please visit The Formula Quick reference guide at: https://na3.salesforce.com/help/doc/en/ salesforce_formulas_cheatsheet.pdf

4. We can also use Insert Field to insert fields in the formula to create a dynamic formula. The fields that can be selected while creating a formula are, $ fields, which are globally available like login user fields. For example: $User.City 5. The fields from related objects such as master object or a lookup object are also available to link in the field name. We can include other custom object fields in the formula field using ObjectType. 6. In the Error Message section, we add the error message that will appear on the page if the validation rule is successful.

The error location determines where the error should appear. If there is a particular field that the validation rule has failed, we can add it on the field level, helping users quickly identify the wrong field.

Formula fields

A formula is similar to a spread sheet formula field that is executed at run time. The formula can make use of existing data to create a new set of data. Here's an example of a formula that can be used in a custom formula field on a media object. It calculates the number of days after the due date is over (assuming, we have all the fields in media object): If(TODAY ()>BookIssueDate__c,TODAY()-BookIssueDate__c,0);

[ 98 ]

Chapter 4

Exercise – calculating the return date

The general library has a fixed pattern in returning the media items. The members are allowed to borrow the media items for only 15 days. They want to reduce the typing work for the entry clerk and wish to auto calculate the return date of the book. The return date will be calculated on the CustomerMedia object that will record the transaction of book issue. To create the Return Date formula: 1. Create a Date field titled Issue Date, this field will store the date of issue for the media item. 2. Create a new field titled Return date as shown in the following screenshot, it is of type Formula and the return type is Date and click on the Next button.

[ 99 ]

Implementing Business Logic

3. The next page is the formula editor. We can create a Simple Formula or an Advanced Formula. A Simple Formula gives us the list of the fields on the existing object on which the formula is written along with some global variables. The Advanced Formula editor helps in writing the cross object formulae. The other highlighted parts are Insert Operator, which helps in building the formula. Check syntax checks for syntax error before saving the formula.

4. Add the formula Issue_Date__c +15 in the formula editor as shown in the following screenshot:

[ 100 ]

Chapter 4

5. Here Issue_Date__c+15 is the date field used to store the issue date for the media. We can also use the Insert Field drop-down list to insert this field. Make sure to click on Check Syntax button to compile the formula and check for errors. Every time a new record is created with the Issue Date, the Return Date field will automatically calculate and store the return date for it.

Cross object formula fields

One of the most powerful features of the Force.com formula are the cross object formula fields. In cross object formula fields we can navigate up to five levels of child-parent-grandparent relationship. Formula fields are calculated on the run time according to the formula stored in the fields. Record owner and activity fields cannot be used in a cross object formula fields. Let us create the cross object formula field for the customer object.

Exercise – calculating penalty

The general library wishes to calculate the Penalty Amount of the media resource when it is checked out late. Write a formula field that can calculate the amount on the Customer-Media object. Use the formula above and assume the penalty amount per day is stored on the media item to calculate the final amount.

To create a formula field first go to the field creation dialog box on the object that we saw in Chapter 2, Creating a Database on Force.com, Force.com data-types section. Select the Formula field in the list of fields. It will open the formula creation wizard.

[ 101 ]

Implementing Business Logic

1. Choose the return type of the formula. For the purpose of the exercise as we are calculating the fine amount on the book, the return type would be Currency as shown in the following screenshot:

The return type does not contain a checkbox or a Boolean return type. In case we wish to create a formula to check whether a record is true or false, use the return type as string and in the formula create T or F as the output.

2. Click on Advance Formula to open the Advance Formula Editor. In the Advance Formula Editor click on Insert Field to open a field pop-up as shown in the following screenshot:

[ 102 ]

Chapter 4

3. The Insert Field dialog box allows us to access fields on different objects that are related to the current object. In this case, we can access the field, Loss Fine, which is stored on the Media object in the Customer-Media object, to generate the formula. To access the field click on the object name with the > suffix. Once the field is selected, click on Insert in the last column. 4. The formula for calculating the penalty amount would be the number of days after return date x the fine amount. The formula editor also provides us with the system dates in system functions. Select the formula for Today from the Functions on the right side of formula editor, as shown in the following screenshot:

The formula quick reference guide on Force.com provides an effective cheat sheet for the formulae. It can be visited at https://na3.salesforce.com/help/doc/en/ salesforce_formulas_cheatsheet.pdf

5. Now we have both the functions and the fields we require in the formula editor, we also need one more field called 'Return_date__c' we created in the previous section. Create the formula (TODAY() - Return_date__c )* Media__r.Loss_Fine__c to calculate the fine as shown in the following screenshot:

[ 103 ]

Implementing Business Logic

6. For now we can skip the Field Level Security step in the wizard, so simply click on the Next button. We will be covering this in the Security Chapter, Roles and Profiles section. 7. Select the appropriate page layout where the formula should appear. A word of caution, if we don't select a page layout, the field is not displayed on the page.

Roll-up summary fields

Roll-up summary fields are used to aggregate child information on the master object. The roll-up summary uses special functions such as SUM, MIN, MAX, and COUNT.

In the roll-up summary field, unlike the formula field, the field is placed on the master object. The values are aggregated in the object. The values are stored in the field and calculated periodically.

Exercise – creating the roll-up summary

The general library wishes to keep a track of the total media items issued to the customer. They want the total number of items issued in a single field called Media Issued against the member record.

[ 104 ]

Chapter 4

The media that are issued against the customer are stored in the CustomerMedia object; we will be storing their count in the Customer object. 1. Go to Customer Object and click on new fields. When your object is the master object for another (in this case Customer is the master for CustomerMedia object) a new type of data type is available, called the Roll-Up summary as shown in the following screenshot. Select the data type and click on the Next button.

2. We will name this field Media Issued. Please fill in the details as shown in the following screenshot and then click on Next.

[ 105 ]

Implementing Business Logic

3. On the next page select the child object available for roll-up. In the example, select Customer-Media as shown in the following screenshot :

As we are counting the number of records, there won't be a need to select the aggregation field. When calculating Sum, Min, Max in the Rollup summary, we need to specify the field to summarize.

4. As previously mentioned we will be skipping the field-level security for now and leave it for the further chapters in security. On the final page, select the page layout to add the field and Save the field. This covers the basic formulae and the logic that help us simplify the work. In the following section we will be discussing how to automate the business processes using workflows and approval process. We will understand the use of workflow and approval process and distribute the workload to people.

Using workflows to automate business processes

There are many processes in an organization that are handled manually, for example: •

If a user does not return the book in seven days, the librarian sends an e-mail reminder to him to return the same



If a user updates his address in the system, an automated update should happen in an external inventory management system or an address book



If a user misses out a payment of a fine or returns a book after the due date, the user is marked as black listed [ 106 ]

Chapter 4

Force.com provides us with a beautiful workflow management system to automate these manual problems. The solution for the problems such as the preceding one is given as a part of logic as a service. A typical flow of a workflow is as follows:

Rule Criteria Record is modified or updated Evaluation Criteria

A logical rule is evaluated

Do something Workflow Action

The workflow helps in automating the business process that usually requires manual intervention.

Exercise – sending e-mail to members

The library management wants to send an e-mail to the member who issues the media resource mentioning the details of the media item and the date of return with it. Create a workflow rule to send it to the member. The following steps will illustrate how to create a workflow: 1. Navigate to Setup | Create | Workflow & Approvals | Workflow Rules as shown in the following screenshot:

[ 107 ]

Implementing Business Logic

2. Click on New Rule to begin. 3. Select the object on which the workflow will be fired and click on Next, in the example we will select Customer-Media object.

4. Give the rule a name and select the Evaluation Criteria. Evaluation Criteria: The evaluation criteria for a workflow can be any of the following: °°

When a record is created or when a record is edited and did not previously meet the rule criteria: This rules triggers during creating and updating the object till the criteria is met. It is not re-triggered once the criteria are satisfied.

°°

Only when a record is created: This is an option to ignore updates to existing records.

°°

Every time a record is created or edited: This option triggers during creating and updating records irrespective of if it still meets the criteria. The workflow is repeated every time there is change in the value. We cannot add time-dependent actions to the rule if we choose Every time a record is created or edited.

For the purpose of the example, the evaluation criteria will be when a record is created or when a record is edited and did not previously meet the rule criteria. Rule Criteria: As already mentioned in the previous section, rules can be evaluated against values or against formulas. The rule selection criteria are the same as we have seen before. For example, the rule criteria would be if the return date is not null as shown in the following screenshot:

[ 108 ]

Chapter 4

5. Click on Save & Next. 6. Click on the Add Workflow Action to select an action as shown in the following screenshot:

[ 109 ]

Implementing Business Logic

Workflow Actions: We can add different actions to the workflow to perform once the workflow rule criteria and the entry criteria are evaluated. We can add the following actions to the workflow: °°

Task: A task is created for any user once the workflow is fired. Tasks are set in the Salesforce calendar and can be directly synchronized with the other calendar application by the user.

°°

E-mail alert: We can also send an e-mail alert to reach recipients if the criteria are met. For example, suppose a book reserved by the member has recently checked in, an e-mail alert will be fired to the customer to collect the book.

°°

Field update: We can make an automatic field update after a certain criterion is met. For example, if we automatically change the status of the book once it is returned, we can update the field using this action.

°°

Outbound message: An outbound message is sent to the external server or web service.

7. Every action will open a new window with respective parameters. Save them. 8. To add more actions repeat step four otherwise click on Done. We can also reuse the workflow actions in the multiple workflows. To reuse an existing action, like, for example, sending a common e-mail for multiple workflows, select the fifth option of choosing Select Existing Action. 9. Once you create a workflow it will not be Active automatically as shown in the figure below.

10. To activate the workflow, do not forget to click on the Activate button on top of the workflow detail page.

[ 110 ]

Chapter 4

Time-dependent workflow

Generally, the workflow action is executed immediately, the moment the workflow is fired. However, in some cases we need to set an action after some amount of time. The general flow of the process is as shown in the next diagram:

Rule Criteria Record is modified or updated Evaluation Criteria

Wait for a X number of days

A logical rule is evaluated

Workflow Action Do something

Time Action

For example, to send a reminder e-mail for due date of a checked out resource to the customer. In these cases we use the time-dependent workflows. The time dependent workflow waits for X number of days/hours/minutes after the workflow is fired. The time duration can be relative to the time of workflow or any date field on the record. For example, five hours after the workflow rule is evaluated or two days after the created date. The time-dependent workflow cannot be used if the Evaluation Criteria is set to Every time a record is created or updated. The effects of the workflow cannot be immediately seen, however pending action can be monitored using the time-based workflow queue. To see the queue, click on Administration Setup | Monitoring | Time-Based Workflow.

If the record has an action pending in the queue and the workflow is modified, this time without meeting the criteria, the pending action is cancelled. If the record has an action pending in the queue and the workflow is updated again and the timing is changed, the pending action is modified with changes.

Exercise – blacklisting the member

The library management wants a clear indicator when the member fails to return the book on the due date. Create a workflow rule to blacklist the member 48 hours after the due date. [ 111 ]

Implementing Business Logic

To create a time-based workflow, perform steps one to three of creating a workflow and then continue with the following steps: 1. Go to the workflow detail page and click on Add Time trigger as shown in the following screenshot:

2. Add the time trigger in the next screen for 48 Hours after the Return date as shown in the following screenshot:

3. Now that a time trigger is defined we can add the action as New Field Update with the time trigger. The actions are common for both types of workflows as shown in the following screenshot:

[ 112 ]

Chapter 4

For a time trigger, please add action below the time trigger and not on the workflow. We can add actions to both places.

4. Save the time-based trigger.

Exercise – creating multiple time-based trigger

In the general library, they wish to send a reminder e-mail to the user about returning the book on time. The user has to return the media item 14 days after the check-in date. Create a time-based workflow that will send a reminder e-mail five days BEFORE the due date. Use mathematics to calculate the time period.

The library also wishes to send the reminder e-mail two days after the due date. However, if the user checks-in the book before the reminder it should automatically stop the alert. Create a time-based workflow for the same. We have already seen how to create a time-based workflow; this exercise is to practice for the same. Use the example given in the section as a reference and create these time-based workflows.

Improving productivity using automated approval process

Apart from automating the process workflows, Force.com also provides a system for automating the approval process. The difference between workflows and an approval process is that an approval process requires a manual decision between the flows. A typical approval process flow is as follows: Record is modified

Approval

Approve

Action Approval Action Approval Action

Submit for approval Reject

[ 113 ]

Rejection Action

Implementing Business Logic

Creating a multi-step approval process

An approval process can be of single step or multiple steps. At every approval stage we can add a set of actions. The following diagram illustrates a typical flow for a multi-stage approval process. At every stage we have a different set of users to approve the record to move it to another level. Record is modified

Approval Step 1

Approval Step 2

Approval Step 2

Final Approval Final Approval

Approve Final Rejection

Approve Final Reject

Approve Submit for approval

Reject Reject

Let us create a multi-step approval process. Before creating the approval process, first check if all the necessary items required for the approval process are in place. We will: • • •

Define the approval process e-mail template Determine who is submitting for approval to whom Determine how many steps of approval are needed

The steps to create an Approval Process are as follows: 1. Click on User Name | Setup | App Setup | Create | Workflow & Approvals | Approval Process. 2. Select the object for which we need the Approval Process and click on User Standard Setup Wizard as shown in the following diagram:

3. Enter the unique name and process name and click on Next. [ 114 ]

Chapter 4

4. Specify the entry criteria. The entry criteria is similar to the entry criteria in the workflow. However, in an approval process it is optional.

5. Select the field for Automated Approval Routing. We can assign the approval process dynamically to the manager of the submitter using this option. If the approver is not the direct reporting manager to the submitter or if the user field is empty for the user, this option can be set blank and the approver can be selected based on the step. This process also applies to the multi-step approval process where every stage has a different approver.

6. Select the Record Editability Properties. By default only system administrators can unlock a record for editing if it is submitted for approval. However, we can choose to also allow the currently assigned approver to edit the record. 7. Select the E-mail Template and select the generic e-mail template to be sent out to all the approvers. We add use the merge fields to prepare the templates to make it look more personal. Please ensure the e-mail template that is selected is available for use.

8. Select Fields to Display on Approval Page Layout. This is a quick way to view the record page where the approver will land on clicking the link through the e-mail. This page should contain all the critical information for decision making for the approver. 9. Select the initial submitters for the approval process. This option helps in determining which users are authorized to submit a record for approval. Also in submission settings we can select Allow submitters to recall approval requests. This option allows users to change their mind and recall the approval request and click on Close. 10. Upon clicking on Close there is a decision box if an approval step is to be added immediately. On selecting Yes the wizard for creating approval steps will pop up. [ 115 ]

Implementing Business Logic

Creating approval steps

The approval process wizard helps us in creating an approval process. The next phase in an approval process are the steps, where we determine to what criteria should the approval process be routed and to whom. The record filtration in the different steps can be visualized in the following diagram:

Note that in step 4 of Creating a multi-step approval process, we did select the entry criteria; we again sub-filter them or let all records enter the approval step depending on the condition. For example, as shown in the preceding diagram the main entry criteria could be discounted by more than 40 percent. However, there are two different managers to approve the discount between 40 to 50 percent and discounts above 50 percent, hence we add the further conditions in the approval steps: 1. Go to the Approval Process detail page. If continuing from the previous steps, then please skip the first two steps and proceed to the third step. 2. Click on New Approval Step, which will open a wizard. 3. Give the approval process a valid name and a valid step number and click on Next. 4. Specify Step Criteria: If we wish to filter the records for different approval steps or let all the records enter in the step. If we filter the criteria also mention what to do with the remaining records, auto approve or reject. [ 116 ]

Chapter 4

5. Select Approver: We have to select the approver for the record in this case. Apart from going to the manager for approval we can assign the record to a queue of users or we can also let the user choose the approver manually. Also we can directly specify the user or users who can approve the record. If the approval is assigned to multiple users (by selecting Automatically assign to approver(s))If we select the checkbox for the delegate to approve the record, the manager's delegate can also approve it. This is called the delegated approval process. 6. This step gives us an option of jumping directly to add the approval or rejection action to the step. The actions are similar to those of workflow action and we will come to that in the next section. Go to the Approval Process detail page to see the work we did.

Approval actions

So far we have created an approval process and added an approval step to it. We can specify the default actions that can happen when the record is: •

Submitted: By default Force.com adds a new type of action to this step which is record lock. However, we can modify this action and unlock the record. This happens when a record is submitted for approval, possible action would be a field update for Status from Open to Under Approval.



Approved: These actions are executed when the record is approved in a step and is still in the approval process. Possible actions can be updating the status to Approved by XYZ or Under XYZ approval.



Rejected: These actions are executed when the record is rejected in a step and is still assigned to someone else. Possible action can be an e-mail alert to the submitter it has being rejected.



Finally approved: As with the submitted action, final approval of the record is also set to lock. It is recommended that the record remains locked to prevent the user from editing the approved record. These actions are executed at the end of the approval process when the record is finally moved out of it. Possible action can be updating the Status to Approved and e-mail alert to the submitter confirming the approval.



Finally rejected: Force.com provides us with a default action of unlocking the record once it is finally rejected. We can change it to lock. These actions happen when the record is finally rejected with comments from the rejecter.

[ 117 ]

Implementing Business Logic



Recall action: Force.com provides us with a default action of unlocking the record once it is finally rejected. We cannot change it. If the submitter has a change of heart once the record is submitted for approval he can recall the record. This is possible only if we set that the submitter can recall the record.

As shown in the preceding screenshot we can specify the action to any of the above steps. The actions are similar to workflow actions and we can also re-use the existing workflow actions in the approval process. Once we finish the approval process and add action to it, we can check the approval process in a diagram by clicking on the View Diagram button. The next screenshot shows the diagram for the approval process. The process visualizer provides the read-only diagram for the approval process.

[ 118 ]

Chapter 4

Parallel approval step

A parallel approval step has many approvers in a single step. The approval process can be assigned to more than one approver; in this case we have two scenarios: •

All the approvers need to approve the record unanimously



A single person in the group can approve the record

[ 119 ]

Implementing Business Logic

A common scenario would be, if you need to get an approval for an amount of more than 10,000 for a project, it will go to the project manager as well as the finance manager for approval. Both approvals are required.

To create a parallel approval process, first create an approval process as mentioned above. Then perform the following steps to create the parallel approval step: 1. Go to the Approval Process detail page. If continuing from the previous steps, then please skip the first two steps and proceed to the third step. 2. Click on New Approval Step, it will open a wizard. 3. Give the approval process a valid name and a valid step number and click on Next. 4. Specify Step Criteria: If we wish to filter the records for different approval steps or let all the records enter in the step. If we filter the criteria also mention what to do with the remaining records, auto approve or reject. 5. Select Approver: Select Automatically assign to approver(s) so we can directly assign the user or the related user. 6. Now we can specify if we need unanimous approval from the user or a single approver is enough.

Comparing workflow and approval process

Workflows and approval processes both help us automate the business processes. Both are given as part of the logic as a service offering by Force.com. Let's quickly have a recap of both the processes. [ 120 ]

Chapter 4

Workflow rules

Approval process

Workflow rules are triggered immediately and automatically after saving.

The record has to be sent for approval manually by clicking on Submit for approval.

The workflow actions are executed immediately or are time-dependent.

There is a separate action for each step giving the approval process.

Has a single set of criteria and action.

Is a multi-step process.

Is completely automated.

Requires manual decision at every stage.

This covers the section of automating a business process using workflows and approvals. In the following section we will be covering an overview of the monitoring tools available for us to monitor the running process in the system.

Debugging and monitoring the process Logs are used to record error and back-end processes that are running in the organization. They store the following process information: •

Workflow and approval process



Assignment rules



Escalation rules



Auto-response rules



Apex Script errors



Resources used by Apex Script

Types of logs

There are two types of debug logs: •

Debug log



System logs

[ 121 ]

Implementing Business Logic

Debug log

Debug logs are stored separately and can be retained. They are stored based on particular users only. We can download, view, and manage the debug log for users. At a time only 20 logs are permitted per user. There is a limit of 2 MB per log and 50 MB per organization. To setup a debug log, navigate to Setup | Administration Setup | Monitoring | Debug Logs.

Click on New and add the user name to monitor in the box. The limit for debug log is 20 logs per user.

[ 122 ]

Chapter 4

System logs

System logs record the overall system processes happening at the moment. They store the processes created by all the users. System logs are not stored anywhere. To start the system log click on Your name | System log in the top header of the page.

The system log will pop up on screen. The system log will monitor things as long as they are open, whereas the debug log will record 20 logs irrespective of if it is opened or no.

Categories of logs

Every category has a different log level. To pinpoint to the exact level, we can filter the categories according to their levels. Every Apex class has its own category filter, which tells the debug log what to record. The log categories are as follows: Log Category

Description

Database

The database is the lowest category in the log. It includes data manipulation language (DML) statements and inline SOQL or SOSL queries.

Workflow

The log for workflow rules, such as the rule name, the actions taken, and so on.

Validation

Validation category shows information about validation rules, such as the name of the rule, whether the rule evaluated true or false, and so on.

Callout

Callout stores the log for the response and the send request from API. This is useful when debugging issues related to using Force.com web services API calls.

[ 123 ]

Implementing Business Logic

Log Category

Description

Apex code

The category stores information about Apex code and can include information such as log messages generated by DML statements, inline SOQL or SOSL queries, the start and completion of any triggers, and the start and completion of any test method, apex classes, methods etc.

Apex profiling

It includes the limits for the namespace, the number of e-mails sent, the number of queries used, and so on.

Visualforce

Includes information about Visualforce events, including serialization and deserialization of the view state or the evaluation of a formula field in a Visualforce page.

System

Includes information about calls to all system methods such as the System.debug method.

Log levels in the system log console

Specific events are logged based on the combination of category and levels. Most events start being logged at the INFO level. The level is cumulative, that is, if we select FINE, the log will also include all events logged below the FINE level. The log levels are listed from lowest to highest. •

ERROR



WARN



INFO



DEBUG



FINE



FINER



FINEST

Not all events have all the log levels, however, most of them will have two or three log levels. We can choose what level of logs we want to record to check the finest code execution.

Using the debug log

We can use the debug log to monitor processes that can have more than one occurrence from the following, but not limited to, events: •

A workflow is not working the way it should be



There is no or a wrong field update [ 124 ]

Chapter 4



The approval process is not assigning it to the correct user



There is an error in the Apex trigger



There is an e-mail alert on a workflow or approval, but we have not received the e-mail. We might want to check if it's firing the alert with the correct e-mail ID.

Summary

In this chapter we covered the basics of logic services provided by Force.com. The controller and the business logic are the most powerful things behind every application. By using the Force.com powerful point-and-click mechanism we can actually solve most of the critical business problems and automate the processes. Thus we complete creating the model-view-controller architecture on Force.com. We have learned the basics of creating the model-views and building the logic. In the further chapters we will now proceed to the fundamentals of building multiple user applications. We will discuss how to set up security and access control to data for users. We will discuss the data loader and massive data operations on Force.com.

Test your knowledge

1. Which one of the following is not possible to view in the debug logs? a. Workflow formula evaluation results b. Assignment rules c. Formula field calculations d. Validation rules e. Resources used by Apex Script

2. Which of the following do we get as part of logic as a service out of box offering? [Select any three] a. Data warehouse b. Approval process c. Workflow rules d. Validation rules

[ 125 ]

Implementing Business Logic

3. Only a particular user with the right profile should be able to submit the record for approval. How do you achieve this? a. Add this condition in the entry criteria b. Choose the initial submission action c. Add this condition in the approval step entry criteria d. Add this condition as a rejection action 4. If the approval process has three parallel approvers in the first step when will it move to the next step? Select any two options. a. Unanimous approval is required and all the approvals are there b. Majority approval is required and majority of approval is there c. Unanimous approval is required and majority of approval is there. d. First approval is there and unanimous approval is not required 5. Under what circumstances is a workflow rule triggered? a. Automatically when the record is saved b. When the user submits it for workflow c. When the manager submits it to workflow 6. Which one of the following can't be a final rejection action in the approval process? a. Lock the record b. Outbound message c. Delete the record and send to recycle bin d. E-mail alert 7. Using an approval process an organization has configured the application to have the first step of the process require approvals from three different hiring managers. Select the two possible approval choices based on multiple approvers for an approval step. a. Approve or reject based on the first response b. Require majority approval from all selected approvers c. Require x out of y approval from all selected approvers d. Require unanimous approval from all selected approvers

[ 126 ]

Chapter 4

8. You have created a time-based workflow rule. Choose from the following two ways to check whether the workflow actions are getting fired or not: a. Check the time-base workflow queue b. Check if the workflow throws any error on screen. c. In the debug log, set yourself as a user and then check the debug log. 9. Which workflow evaluation rule doesn't support a time-dependent workflow? a. When a record is created, or when a record is edited and did not previously meet the rule criteria b. Every time a record is created or edited c. Only when a record is created 10. In MVC, data model refers to? a. Custom fields b. Custom tabs c. Workflow rules 11. In a Master-Detail relationship scenario where the fields of the parent object needs to be displayed in the related list how will a developer design this? a. Cross-object formula field b. Workflow rule c. Validation rule d. Assignment rule 12. In a recruiting application a position that is of type "Critical" should not be open for more than 14 days. How will you develop the business logic to cater to this? a. Time-dependant workflow action to send an e-mail to the owner after 14 days b. Time-dependant workflow action to send the record for review to owner after 14 days c. Time-dependant workflow action to send an e-mail to the owner before 14 days d. Time-dependant workflow action to close the position after 14 days

[ 127 ]

Data Management We have seen the MVC architecture of Force.com. The MVC model helps us separate the business logic from the display and data. Now, we can build an application on Force.com using the previous chapter. For an effective application, having correct data is as important as having efficient business logic. As we have already seen in Chapter 1, Getting Started with Force.com, Force.com is suitable for data-driven and process-driven applications, hence the data operations are massive. Force.com provides us with some really nice and efficient tools to manage, manipulate, and clean massive data per iteration. In this chapter we are going to learn: •

How to import data using the data loader



The standard data management operations



How to import data using wizard



How to execute the data loader via command line



Some lessons in Force.com IDs

So let's start playing with the data.

The basics of data operations

When we migrate an application on Force.com there is a very important process of migrating the data from the existing legacy system or spread sheets and loading it into the cloud application. To improve the data quality we also need to ensure that there are no duplicate entries and the data is clean.

Data Management

Some basic data management operations are: •

Data export: °° °°



Inserting data: °° °°



We can insert data into existing standard and custom objects Also helpful in migrating users

Updating data: °° °°



Data can be exported for making periodic backups or downloading the entire data It can also be used to get the template to insert data

Updating is needed to run a de-dupe check to remove duplicates It is also used for enhancing or cleaning the data

Deleting data: °°

The deleting operation is used to free up legacy data and to remove erroneous data

We will be seeing the above operations using the data loader, using a wizard as well as using the command line interface.

The importance of record IDs

Why do we have a separate section on record IDs? Once we master them, most of the data operations are a piece of cake. The record ID is a unique identifier of the record. The record ID is similar to the primary ID and foreign ID in a database table. The SalesForce.com record IDs are not just a bunch of random numbers, but have valuable information that can help us.

18-character and 15-character IDs

Force.com uses two types of IDs, 18 character and 15 character. When we use the ID from the URL it is 15 characters, however, when we use the data loader we get 18 character IDs. The 15-character ID is case sensitive while the 18 character ID is not case sensitive. The 18-character ID is used to migrate data from legacy systems or spread sheets, which do not recognize case-sensitive IDs. Both the IDs work with Force.com and point to the same record. However, if we are to migrate data from the spread sheets or export data to the spread sheets we have to use 18-character IDs. [ 130 ]

Chapter 5

There are three ways of getting the record ID, they are as follows: 1. URL of the record detail page. 2. By running a report on the object. 3. Data loader (API access). URL and report will always return the 15-characters IDs while the data loader and the API return the 18-digit IDs. API, however, accepts both 15-character and 18-character IDs. Let us now explore what we can gain from IDs in the URL.

Exploring the URL format

The easiest way to study the record ID is by understanding the standard Salesforce objects. These IDs are fixed and are of similar format across the Salesforce organization. Every custom object will have a fixed pattern, but will be unique to individual organizations only. For the purpose of an example we will study the record ID of opportunity object. Open an opportunity record as shown in the following screenshot:

If you do not find it on display, please select the Standard Sales Application using the drop-down in the corner.

[ 131 ]

Data Management

The record ID is seen in the address bar of the browser as shown in the following screenshot:

Let's observe the format of the URL of the address bar carefully, the URL is made up of different things as shown in the following screenshot:

Let us now look at the different parts of the URL separated in the preceding screenshot. •

Instance name: The first part of the URL is the instance name. Salesforce. com provides multiple instances of the server and the instance name varies depending on the time and location from where you create the ID. For the full list of instance name and their status please visit: http://trust.salesforce.com/trust/status/



Salesforce Server URL: This is common for all the record IDs.



Record ID: The third part of the URL as seen in the preceding screenshot is the Record ID. The format of the URL is common for all the detail page of the records across the organizations. We will be looking at the Record ID in greater detail in the next section.

Record ID

One important thing to note is that the record ID is case sensitive. So 00690000003zRfq is not equal to 00690000003ZRFQ. There will be a unique ID per organization, no two records will have same ID. When we migrate data from one organization to another, the IDs are changed. The record ID is further split into two parts as shown in the following screenshot:

The first three characters of the record ID are the object identifiers, which help us to identify the object of the record. [ 132 ]

Chapter 5

The remaining characters are the unique record ID to identify the record. All the objects thus have three-character encoded ID, which is a prefix to their record ID elsewhere. The following table shows us the three character prefixes and the objects that they are associated with: Prefix

Object Name

001

Account

003

Contact

005

User

006

Opportunity

00e

Profiles

00Q

Leads

00T

Tasks

00U

Event

015

Document

01t

Product

500

Case

701

Campaign

800

Contract

These prefixes for the standard objects are the same across all the Salesforce organization. Now let's play with the URL a bit. If we wish to land on the list view of the standard object, all we need to do is append a /o against the object prefix example for the account object we need to add 001/o. The final Salesforce URL in this case would be:

The instance name for every organization would be different. The name depends on the geography and the time when the Salesforce account is created, please check the instance name for your organization.

This will open the list view or the tab view of the object, similarly we can change the prefix to any standard object. [ 133 ]

Data Management

When we change the /o to /e it automatically opens the edit page for a new account:

This will open the edit page for the account directly. If we add the /e in front of a record ID, we get the update detail page for the record, for example, let's say we want to open the opportunity edit page from our original example. \

Now if we add the /e in front of the URL, we get:

This will automatically open this opportunity for editing; try adding a /e against any record URL and we will get the edit page for the record with all the existing data prefilled with information. Only when we create the full-copy sandbox of the production organization, do we get similar IDs in productions and sandbox only once. Record ID in the field is not editable even in code. We cannot include it in DML for insert, but will be useful for DML of update and delete.

Summarizing record IDs

Let us recap some important points we learned about record IDs: •

A record ID is similar to the primary or foreign key in a database



Record IDs are case sensitive on Salesforce.com



18-character IDs are case insensitive



Every record ID has a prefix of the first three characters



Every record in multiple and similar organizations have a different ID



IDs are similar only for the first time when we have a full-copy sandbox of a production organization [ 134 ]

Chapter 5



18-character IDs are used for migrating data from a legacy system that is case insensitive

Relationships — dependents first

The first lesson we learned in the book was that Force.com is a relational object oriented database. Let us revisit the objects that we saw in the first chapter of the book. In the general library system we have the following relationships: The object Customer is related to Media through a junction object CustomerMedia. Media object is a master for books and video objects as shown in the following diagram:

Media M

1 Customer

CustomerMedia M

1

As shown in the following diagram, Fine has a Lookup on Cards:

Cards

Lookup CardFines

Fine

[ 135 ]

Data Management

Finally, as shown in the following diagram Card has a Master-Detail lookup on Customer:

Customer

MasterDetail

Owns

Card

When we load data we have to load in the order of dependencies, for example, in the library system the CustomerMedia object is dependent on the Customer and Media object. Hence, to load the CustomerMedia object we use the following sequence: 1. Load Customer object data. 2. Load Media object data. 3. Finally load the CustomerMedia object data. The rule of thumb when uploading the data is that every dependent object data should be loaded first. As the CustomerMedia object had two dependencies, one on Customer object and another on Media object, we loaded both the data first.

Modifying system fields

When we are loading legacy data into the Salesforce system during migration it is sometimes essential to change the Created Date, Last Modified Date, Last Modified by, and Created by entries. Normally, when we load data into the system, the dates are not modifiable and are system time stamped. However, Salesforce.com provides us with the facility for modifying the auditing fields only once during the first insert. This is helpful in migrating legacy data and preserving history. To enable this feature we need to contact Salesforce customer support.

[ 136 ]

Chapter 5

Features of modifiable system fields

Some of the important features of modifiable system fields are as follows: •

The fields can be modified only once in the lifetime of the initial insert



They are accessible through API, that is, the data loader



All custom objects can have modifiable system fields, however, not all standard objects can have modifiable fields



Account, opportunity, contact, lead, case, task, and event can have modifiable fields



The fields are read-only for existing records

Connecting to Salesforce server through API

When loading the data from a data loader, we make an API call for the Salesforce server. The login credentials are passed through the user name + password + security token. We can bypass the use of a security token if we white list the IP address from where the data is loaded.

The CRUD commands

The full-form of CRUD is create, read, update, and delete. Force.com provides us with all the four operations using API. Records can be inserted, updated, deleted, and extracted from the server. The inserting process requires data to be inserted without the ID because Force.com generates the record ID when the record is created. Data is uploaded in the form of a .CSV file created using a spread sheet. We can map individual fields to Force.com, however, to save time we can initially extract a single record with the selected fields and use it as a template to quickly map other fields.

The update process is the same as insert, but since we are updating an existing record we need we need an ID or an External ID during update. The delete command only needs the ID of the record to be deleted.

[ 137 ]

Data Management

Apart from the general CRUD commands Force.com provides a special upsert command. Upsert is the combination of insert and update in a single call. Upsert uses ID or external ID to match records with existing records, if no match is found or the ID is missing, it inserts the record. The upsert command is helpful in avoiding duplicates based on ID or external ID. If more than one record is matched, an error is reported.

External IDs

When we are migrating data from other systems, it is useful to have a foreign key to link data between the two systems. The external ID helps to create that link. A custom field can be marked as an external ID to identify the primary keys of the legacy system (outside Salesforce). Text, number, e-mail, and auto-number fields can be flagged as external IDs. Fields marked as external IDs are indexed and are available on all the objects that can have custom fields. These fields are searchable and appear in search queries. An object can have three external ID fields. The external ID fields become the cross reference fields to the legacy systems. For example, if the following data is in the legacy spread sheets for the library system we can migrate it to Salesforce by mapping the Media Number to the Media Number External ID field. The original data from the legacy system are given as follows: Media Number

Media Name

Media Type

1

Harry Potter and the chamber of secret

Book

2

Freakonomics

Book

3

Mission Impossible

Video

We can map this legacy data to the Force.com fields using the following mapping: Media_Number__c

Name

Media_Type__c

1

Harry Potter and the chamber of secret

Book

2

Freakonomics

Book

3

Mission Impossible

Video

(External ID)

[ 138 ]

Chapter 5

When we are migrating data from the legacy system into the Salesforce.com system, we can upsert the data using the external ID field. This way there is no need to know the Salesforce record ID. We can prevent duplication of data using the external ID. We can also load data into related objects without using ID. Ideally, when loading data into related objects, we need to include the Salesforce ID as the field name in the data files, but we can also include an external ID and perform an upsert. Using the external ID while loading relationship is only permitted during the upsert operation.

Exercise – migrating data from legacy system The general library wishes to migrate the media information from the spread sheets they are using. They have a field called Media Number in the spread sheet, which is a unique identifier (primary key) in the current system. Migrate the data into the media object and avoid duplicates. To migrate the data from the spread sheet, we first need to create an external ID field in the media object. Recollect how to create the custom field on the object from Chapter 2, Creating a Database on Force.com. Create a Media_number field on the media object in Salesforce, the field can be a text field. Check the flag for external ID to flag it. While loading the data use the Media_ number field and use upsert to load the data.

Data loading tools

There are two methods provided by Force.com that help us in data migration, Cloud Import Wizard is a cloud-based tool and does not require any download. It is easy to use and quickly lets us upload few standard objects and all custom objects. Apex Data Loader (API based) is a downloadable utility that has many more advantages over the cloud-based tool. Let us look at both the tools in details:

Cloud-based data import wizard

The cloud-based data import wizard is a cloud-based solution to import data into the organization quickly. It is a easy-to-use tool to load accounts, contacts, leads, solutions and custom objects. We can load up to 50,000 records at a time. It is accessible only to the system administrator or profile with administration access.

[ 139 ]

Data Management

To use the data importing wizard perform the following steps: 1. Navigate to User Name | Setup | Administration Setup | Data Management as shown in the following screenshot:

2. We can import data in all the standard objects using the cloud-based data wizard hence Force.com provides us with the option of choosing from the following wizards: • • •

Import Accounts/Contacts Import Leads Import Solutions

Similarly, Force.com also provides us with a separate Import Custom Objects wizard that helps us load data in the custom object. Select the Import Custom Object Wizard for the exercise. 3. On the next page we see basic instructions for using the wizard and on the final line we see the link to start the wizard. Click on Start the Import Wizard! as shown in the following screenshot:

[ 140 ]

Chapter 5

4. A new wizard will pop up as shown in the next screenshot; it contains the list of the entire custom object available for import. Select the Media object and click on Next.

5. The next step confirms if we want to set the de-dupe check before inserting the records. Select Yes, to enable the de-dupe check as shown in the following screenshot: If the Media Number is created as an External ID field it will be reflected on this page. If it is not and there are no external IDs, the radio button would be disabled.

[ 141 ]

Data Management

6. The Data Import wizard lets us import special relationships using name, record ID, or any external ID. On the next screen, we can choose the owner field for the records:

7. As the media object has record types, the next screen allows us to choose the Record Type of data to be inserted. We can insert only one record type at a time.

8. Select the .CSV file to upload. The file should have the column headings as the first row, this is helpful in identifying the column type and easy to map. On the next page, we can map the fields to the Salesforce columns as shown in the next screenshot. Map the columns from Excel to Salesforce fields and click on Next.

[ 142 ]

Chapter 5

9. On the next screen it will show errors if any and give general warning messages regarding updates. All the fields that are universally required should be mapped with some value to upload.

If we do not specify the OwnerID while uploading, the user who uploads the file is assigned the owner of the entire records.

10. Finally, click on Import Now, we will receive an e-mail when the import is completed.

Apex data loader

The Apex data loader is a .net utility used to upload data to the organization. We can load any object that has API_Access. Unlike other tools, the data loader is not a cloud-based tool, but a desktop utility built for systems running on windows. Some features of the data loader are: •

The Apex data loader is available in unlimited edition, enterprise edition, and developer edition orgs



It supports the CSV (Comma Separated Value) format to load data and export data



It is a useful tool to backup and archive your office data



The data loader also runs on command line

Some salient features of the data loader are listed as follows: •

The Apex data loader is an API-based tool used to load Salesforce data



We can load more than 50,000 records using it and also schedule data loads



Data can be exported and mass deleted



The Apex data loader can run from the command line



There is no limit for 50,000 records



We can export data for backup and mass-delete



We can also schedule the data loading at regular intervals



Data can be imported and exported using CSV and JDBC

[ 143 ]

Data Management

Downloading the data loader

Unlike other features of Force.com, the data loader is not completely on cloud. We need to physically download and install it on the machine to use. To obtain and install the data loader perform the following steps: 1. Navigate to User name | Setup | Data Management | Data Loader. 2. Download the Data Loader.

An unofficial Mac version of the data loader is also available at http://www.pocketsoap.com/osx/lexiloader/

3. Launch Install Shield Wizard and follow the instructions. Install the data loader in the machine, before the proceeding to the next section. In the next section we will be loading data.

Using the data loader

The data loader helps us in exporting data for backup, inserting data, deleting and hard deleting the data as shown in the following screenshot:

Let us export some opportunities for the purpose of an example: 1. Click on Export on the Apex Data Loader. 2. If you are not logged in it will ask for a login. Please ensure you append the security token to the password as shown in the following screenshot and click on Next.

[ 144 ]

Chapter 5

3. Select the object to extract data from and the folder in which the data should be extracted. Ensure you give the file name as .csv as shown in the following screenshot and click on Next.

[ 145 ]

Data Management

4. Prepare the query in the next screen as shown in the next screenshot. Select the fields to download from the field chooser, situated on the left. We can add conditions to the query using the condition box on the right. 5. Don't forget to click on the Add condition button to add the condition in the query. 6. The final query is formed in the wide input text box, which includes the fields and the conditions.

7. Click on Finish and it will start extracting. If there are some errors the final report will show two files success.csv and error.csv. 8. Error files will have the reason for the error in the last column. 9. The finished data will be extracted in the file.

Upserting data

Now that we have exported the data, let us try upserting the data. For the purpose of this example we will upsert the data using the template from extracting it. It is always advisable to extract the fields that we are supposed to update, insert, or upsert so that we get a template. Perform the following steps to upsert the data: 1. Click on the Upsert button on the main screen of Data Loader, select the object for upserting and click on Next: [ 146 ]

Chapter 5

2. In the next screen, choose the matching ID. If there is an external ID field defined in the drop-down there will be an option to select the external ID. This ID is important to determine the duplicates before loading.

[ 147 ]

Data Management

3. In the next page we prepare the mapping to map the fields in the CSV file to the fields on the object. As shown in the next screenshot, click on Create or Edit a map. We can also save this map for future use.

4. As shown in the following screenshot, we can map the Salesforce fields displayed on the top to the fields in Excel displayed at the bottom.

[ 148 ]

Chapter 5

5. Drag the respective fields from the Salesforce object over the fields from the CSV file. If the column headers in Excel are the same we can directly click on the Auto-Match Fields to Columns. 6. We can also save the mappings in an external file for future use. Finish the mappings and click on Next. 7. The wizard asks you to choose a directory in the next screen. This directory is where the success and error files are created. If some new records are inserted, the success file comes with the ID of these new records while the error file comes back with the error code.

8. Select the directory and click on Finish. Thus we have seen the commands of export and upsert using the data loader. The commands of insert and update are very similar to upsert. However, they won't apply mapping with an external ID. The operation of delete and update requires a Salesforce ID.

[ 149 ]

Data Management

Setting up the data loader

By default the data loader is configured to operate using some default parameters. We can further configure it as per our requirements to improve performance. The data loader by default works only with the production organization. To make it operable with the sandbox, we need to modify some parameters. Let us configure the data loader for sandbox operation. Go to Settings | Settings in the Data Loader. A new window will open as shown in the following screenshot:

[ 150 ]

Chapter 5

There are five major configuration changes that we need to keep in mind while setting up the Data Loader. Let us look at each one: 1. Server Host(clear for default): Server host is the end point URL where the data loader should connect. By default the server host would be https:// login.salesforce.com. This end point URL is used when we are uploading data to the production organization or the developer organization. When we are uploading data to Sandbox, however, we need to change it to https:// test.salesforce.com. 2. Use Bulk API: By default the maximum Batch size (5) is 200 while uploading using the data loader, however, if the data is large we can use the bulk API which increases the batch size to 2,000. 3. Start at row: If our batch operations are suddenly interrupted at any point, the record number is indicated on the label of this field. We can choose to resume the operation from this number. 4. Insert null values: When we are uploading the data using the data loader we can specify if the blank spaces should be treated as a null value. This is especially helpful while inserting Date and Date/Time field. When using the Bulk API (2) trying to insert the blank values throws an error. In this case, when using this checkbox with the null values replace all the blanks with #NA. 5. Batch Size: The data loader loads data in batches of fixed size. The maximum batch size of a normal data loader is 200, while the maximum batch size of loading using bulk API is 2,000. With batches multiple records are inserted in a single shot, for example if we are loading 1,000 records, the normal data loader will send request to Force.com with five times the data. However, the cloud import tool can do the same operation in just a single request. We can reduce the number of batch size, but we cannot increase it beyond maximum.

Using data loader through the command line

The data loader is a very easy and intuitive tool to use for loading data. As easy as it is to use, however, it is also requires manual intervention and a user input to operate. However, many times we require automated process to upload large chunks of data. For these cases we use the data loader through the command line interface. Command line data loader performs the same operations as the normal data loader without the GUI and the easy-to-use interface.

[ 151 ]

Data Management

Configuring the command-line data loader

Before we fire up the data loader with the command line interface we need to configure it so that it can perform the desired operations. The main configuration file is config.properties file, which is located in the Data Loader folder. The default location of data loader is: c:\Program Files\ salesForce.com\Apex Data Loader 22.0

For help using the command line data loader give the command -help at the command-line. As the command line data loader runs on the command prompt we have very few options to customize and format the commands during the operation. To overcome this, we prepare some files that store the basic commands and configuration needed to run the data loader from command line. Let us look at some of the files used in operation.

Preparing the process-conf.xml file

The process-conf.xml file contains a description for every potential process that could be called from the command line. Each of these processes is referred to as a Process Bean. A sample Process-conf.xml file is shown in the following screenshot:

The section marked in the outer rectangle is a single bean, which holds the data operation. The following are the main properties: •

Name: Name is used to identify the bean in the config.properties

file and when we call it from the command line interface, for example,

accountMasterProcess.

[ 152 ]

Chapter 5



sfdc.entity: The Salesforce object that is the target of the actions. The value



process.operation: This attribute identifies the type of operation for example, insert, upsert, update, and so on.



process.mappingFile: This attribute identifies the mapping between the fields in the source file (dataAccess.name) and the Salesforce object. This mapping file is a .sdl file. This file can be easily created from the GUI of the

of this property is case sensitive. For example, Account (note: Capital A).

data loader.



dataAccess.type: This attribute identifies the operation to perform on the source file, For example, if we are using the ODBC data source the property will read databaseRead, if we are including data from CSV, the property will be CSVRead.



sfdc.username: This stores the Force.com login name for the command line



sfdc.password: The configuration file is stored as a plain text on the

run. If there is no owner name record specified, this will be the new owner.

machine, storing the password in the file is not a good and secure way. The sfdc.password and process.encryptionKeyFile serve the purpose of encrypting the password for added security. To generate the key and the encrypted password, the data loader provides the utility Encrypt.bat with its installation. We will be looking at Encrypt.bat file in the next section.

These are the entities in process-conf.xml file. This file has to be prepared every time we need to perform operation. If we need to perform multiple operations in a single time the entire should be repeated with all the parameters inside it. Once we configure the desired files we are now ready to run the operation. To run the command line job, the data loader comes with a process.bat file kept in the Data loader folder\bin\ folder. To run the batch process we run the process using the name of the command as input. process ../accountMasterProcess In this case, process is the command given to run the data loader and accountMasterProcess is the name we have given for ID in Bean attribute.

Encrypting a password using Encrypt.bat

To login to the Salesforce.com organization, we need to specify the passing in the config.properties file. For security purposes the password should be stored encrypted so that no unauthorized person can read it.

[ 153 ]

Data Management

Salesforce provides us with the encrypt.bat utility that encrypts the password from plain text. The utility is available at the default location Data loader folder\bin\ encrypt.bat. encrypt.bat runs in the command line and supports the following commands:



Generate a key: This command generates a key from the text we provide.



Encrypt text: It performs the same operation as generating a key, only it can



Verify encrypted text: It matches a plain text and the encrypted password

Usually we should provide the password with the security code in plain text format to generate an encrypted key. be used to encrypt the general text provided.

and prints a success or failure message.

Troubleshooting the data loader

If there is some error in the operation of the data loader we can access the log files of the data loader. The two log files are: •



sdl.log: It contains a detailed chronological list of data loader log entries.

Log entries marked ―INFO are procedural items, such as logging in to Salesforce. Log entries marked ―ERROR are problems, such as a submitted record missing a required field. sdl_out.log: A supplemental log that contains additional information not captured in sdl.log. For example, it includes log entries for the creation of

proxy server network connections.

These files are present in the temp folder of the system running on Microsoft Windows and can be accessed by entering %TEMP%\sdl.log and %TEMP%\sdl_out. log in either the Run dialog.

Apex data loader versus cloud-based import wizard

The data loader and the web-based tool perform similar operations. This is a quick comparison of what to use in what kind of cases.

[ 154 ]

Chapter 5

Apex data loader

Cloud-based import tool wizard

Supports more than 50,000 records.

Good to import records less than 50,000.

Supports all the objects available for data important.

Supports only few important objects for data important.

We want to schedule the data imports example daily import, nightly import.

We need an automatic de-dupe check based on account name and site, contact e-mail address, or lead e-mail address.

Other data manipulation wizards

Force.com provides us with some special data manipulation wizards used for some specific operations. The mass transfer records wizard is used to change the owner of multiple users. The mass delete record wizard helps us delete multiple records in a single operation. Let us look at these two wizards in detail.

Mass transfer records

When we upload data records into the system they can be directly associated with the owner of the record, but if the owner is not specified they are associated with the person who uploads the record. In this case, it becomes tiresome to change the users on every record, especially when the records are large in numbers. To solve this problem Force.com provides us with the mass transfer of records tool. It is a simple cloud-based utility that changes the ownership of the record from one owner to another. Let us see how to mass transfer the records from one user to another. The mass transfer record requires the Mass transfer permission on the profile, and Edit and Read permission on the records being transferred. These permissions are available on the profile of the user; we will be studying the user profile in the Security Chapter later in the book.

[ 155 ]

Data Management

To mass transfer records perform the following steps: 1. Navigate to User Name | Setup | Administrative Setup | Data Management | Mass Transfer Records as shown in the following screenshot:

2. Select the object to transfer, for example, let us select the Media object and transfer the records from one user to another as shown in the following screenshot:

As mentioned before we need Edit and Read permissions on the object records that are being transferred, only those objects will be seen on the page for whom we have those permissions.

[ 156 ]

Chapter 5

3. Select the user who we want to transfer the records from and the user who we want to transfer the record to. If we do not select the user to transfer records from, all the records filtered by the filters can be transferred. Click on Find.

4. Based on the search criteria it will bring the records to transfer below the search box as shown in the screenshot. Select the records that you want to transfer and click on the Transfer button.

5. The records are transferred immediately. When we transfer the standard objects such as Account, we get additional options to transfer related records from the object such as transfer opportunities, and transfer cases, along with the Account object as shown in the following screenshot:

[ 157 ]

Data Management

Mass delete record and delete all data

Some of the other data operations include cleaning the organization database using the mass delete wizard and deleting all data. Warning: Delete all data has no undo option, it formats the organization.

The mass delete wizard helps to clean the data from the organization. To mass delete records from the standard objects, perform the following steps: 1. Navigate to User Name | Setup | Administrative Setup | Data Management | Mass Delete Records as shown in the following screenshot:

2. For now, the Cloud Mass Delete Record tool only allows the mass deletion of standard objects. Let us try to delete a few accounts as an example. Select the Account object for mass deletion. 3. On the next page, we get a complete single page wizard for mass account deletion. The first two steps are for information; step three is an account filter as shown in the next screenshot. The data filters are used to filter out the data for deletion. [ 158 ]

Chapter 5

4. The next two steps in the wizard are additional information while deleting the records as shown in the next screenshot. These steps are unique for the Account object and other standard objects will have different steps.

5. A final checkbox confirms if it is a hard delete or soft delete. If we choose to permanently delete the records, they cannot be recovered. Use this option only if you are absolutely sure you want to delete these records.

Data storage limit

The storage limit of Force.com servers depends on the number of licenses and the type of license we have. With Professional and Enterprise user licenses, we get 20 MB/user with a minimum storage of 1 GB, and unlimited user licenses get 120 MB/user. It is highly recommendable that we clean the data periodically to remove unwanted records. Additional storage can be purchased in blocks of 50 MB and 150 MB from Salesforce.com.

[ 159 ]

Data Management

Summary

In this chapter we have seen the crucial data operations on Salesfoce.com. We have studied the two ways provided by Salesforce.com to perform massive data operations. Let us summarize the entire chapter in a few sentences. The data loader is a client application for the bulk import or export of data. Use it to insert, update, delete, or extract Salesforce records. Similarly, we have web-based import wizards, which are available in the Data Management menu in the setup. We have seen the difference of when to use what. We now have an understanding of the data operations. In the upcoming chapter we will be building the application online and learning how to share the data between users.

Test your knowledge

1. Out of the following what are the capabilities of the data loader? (Choose three) a. Insert more than 50,000 records. b. Insert, delete, and update records for custom objects c. Insert records to different objects in a single operation d. Perform rollback e. Run a batch process

2. The library wants to import updated titles of the media items from their external servers every night at 1 p.m. What can be used for the scenario? a. Import wizard b. Data loader c. Data loader using command prompt d. Scheduled jobs e. None of the above 3. The library wants to update the records in the system. What do they need in the .CSV file before the update? a. Salesforce record ID b. Any unique name for record c. External ID

[ 160 ]

Chapter 5

4. By using which tool can the developer change the data model of an Salesforce organization? (Read carefully) a. b. c. d.

Data loader Administrator setup Cloud based data wizard Other

5. If you want to load the users of the library system in Salesforce using import wizard what issues would you face? a. Can't load custom objects through import wizard b. Can't load users through import wizard c. Can't load around 50,000 records through import wizard 6. An organization wants to leverage the import wizard to import different types of data. What type of data cannot be imported through the wizard? a. b. c. d.

Accounts and contacts Leads Custom objects Users

7. The system administrator has created a new custom object and application. This individual now needs to populate the new object with 1000 records which are formatted in a CSV. Is the Import Wizard appropriate for this task? a. Yes b. No

[ 161 ]

Analytics and Reporting Salesforce provides us with some good tools to create reports and graphical charts. We can create reports and charts using a simple point-and-click tools. By the end of this chapter, we should be able to: •

Identify which report type is suitable for business needs



Create custom reports



Create graphical dashboards



Schedule a dashboard for automatic refresh



Set up an analytical snapshot

The most important function of an enterprise-level application such as CRM is how it displays the reports. As the application performs a large amount of data operations and manipulations, performing analytics and creating visual graphs from the data is very important. Reports and analytics are two one of the most powerful tools given by Salesforce.com. In this chapter we are going to look at some of the most important aspects of analytics provided by Force.com. We have loaded all the necessary data to generate a report in the last chapter. Now let's start building one.

Displaying tabular data using Reports According to Wikipedia, A report is a textual work (usually of writing, speech, television, or film) made with the specific intention of relaying information or recounting certain events in a widely presentable form.

Analytics and Reporting

In simple terms reports are tabular representations of large amounts of data. They can be conditional reporting, for example, a report of all the books purchased in the last quarter or a future forecast or report on the number of books that will be returned by members in the next week or the collection of the entire data, and a report on the number of books in the library. Salesforce provides us with standard reports for the different sets of data of standard objects by default, which is available under the Reports tabs as shown in the screenshot below.

[ 164 ]

Chapter 6

We can also create custom reports on the standard and custom objects for our application. There are three types of custom reports. Let us look at each one of them in detail. •

Tabular reports: Tabular reports are similar to a spreadsheet; they consist simply of an ordered set of fields in columns, with each matching record listed in a row. These types of report populate tabular data without subtotals or aggregation of any column. They are good for representing detailed data of objects for auditing purposes. They can't be used to create groups of data or charts, and can't be used in dashboards unless rows are limited. Examples of tabular reports are library blacklisted members lists, media inventory reports and so on.



Summary: This type of report allows the user to group rows of data, view subtotals, and create charts. They can be used as the source report for dashboard components. This type of report can be used to show subtotals based on particular fields. For example, a report of available movies in the library categorized by their release date, and a report of available books categorized by their authors.



Matrix: Matrix reports allows the user to group and summarize data by both rows and columns. They can be used as the source report for dashboard components. This type of report is used for comparing related totals, especially if there are 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. For example, a report of the available movies in libraries categorized by movie director and release date.

Creating a report

The report builder is the quick and painless way of creating amazing custom reports. To avoid confusion let us quickly see a flow chart for the activities we will be doing to generate the report.

[ 165 ]

Analytics and Reporting

The process of creating a report is summarized as shown in the following image:

Select generate report

Choose the report type

Tabular

Summary

Matrix

Select Rows to group by

Select columns to group by

Select columns to appear

Select order of columns

Select Filters

Select Colours and highlights for charts

Select generate report

[ 166 ]

Chapter 6

Let us create a report following every step from the flow chart in detail: 1. To create a report, first go to the Reports tab. If the tab is not available on your application click on the + on the tab and select reports. 2. Click on Create New Custom Report on the tab as shown in the following screenshot:

3. Select the data object and the report type and click on Create. On clicking Create it will launch the report builder. The report types are generated based on the relationships of the object with other objects. We can also define a custom relationship and create reports on completely different objects. We will study how to create custom report types in the next section.

[ 167 ]

Analytics and Reporting

Report builder overview

The report builder is the easiest way to generate a report. The report builder provides us with different sets of options for different types of custom reports. The following is the report builder interface for a tabular report. As seen in the preceding flow chart, most of the steps in all three types are similar. Matrix and Summary reports have additional steps that we will discuss later.

[ 168 ]

Chapter 6

The report builder is shown in the preceding screenshot. The most important features of the report builder are marked in numbers. Let us see what each number corresponds to: 1. This option lets you choose the type of report to build. The options as discussed before are Tabular, Summary, and Matrix. 2. The list of all the fields on the object is displayed in the panel on the left. We can drag-and-drop any field as the column on the main panel, marked by 3. Additional filters to select the columns are given on the top of the left panel. They include, display all columns, display only text, display only numeric and show only date fields. The column filters help in choosing the fields. 3. The fields are dragged as the column on the main stage. Once the fields are brought on the stage we can set them to sort according to the field as shown in the following screenshot:

[ 169 ]

Analytics and Reporting

4. We can set additional filters for data to get specific reports as shown in the following screenshot:

Field filters let us choose the data according to the field, for example, the account name begins with XYZ or the account city is San Francisco. We can also limit the rows based on the field, for example, top five high revenue generated accounts or five members with maximum number of dues in the library.

[ 170 ]

Chapter 6

The reports can be drilled down based on the data as shown in the figure, for example, generating a report for all the accounts in current fiscal year and so on. There are additional steps for matrix and summary reports as shown in the next screenshot. These options are seen only when we select matrix and summary in the report type. The following screenshot is for the matrix report type:

The additional options provided during the matrix and summary report are as follows: 5. Select the field to group by for rows and columns. For a summary report only one option is seen on the main page to group by rows. The fields are dragged in the place holders to group by the fields. 6. The add chart option the chart option helps us add a custom chart to the report. We can also create the chart while creating the dashboard. When we click on add chart, it gives us additional options to choose the chart type and its value as shown in the following screenshot:

[ 171 ]

Analytics and Reporting

We will look at the option for creating charts in detail while creating the dashboard. After we enter all the values all we do is click on run report and watch it fetch data. When we preview the report in the report builder, only subsets of values are used. A report will return only those values that are accessible to the user. Every user who runs the report will store the values according to his own access settings. Hence, it is important to store it in proper folders to prevent unauthorized viewing of data.

[ 172 ]

Chapter 6

Other options

Once the report is generated, we get the following options.

The reports, once generated, give us the following options. The numbers correspond to the numbers on the previous screenshot: 1. Changing the time frame. We have already set a filter for generating reports, the time frame can also be changed from this block once the report is generated. 2. The report can be exported offline to other spread sheet applications using this option. 3. The report is generated as a plain text output using the printable view. 4. The report can be saved as a copy using the Save As option. 5. Customize opens the report builder again. 6. Run Report lets us recalculate the report based on new data. This is useful if data is time dependent.

Scheduling a report

Not only can we run the reports on the browser, we can also schedule it to run at a specific time and e-mail particular reports on time. This way we can fetch the data such as end of the day sales reports and so on, without manual intervention. To schedule a report, first follow the entire step and generate a report. On the report page as shown in the next screenshot select the arrow beside the run report. In the drop-down select the Schedule Future Runs… option.

[ 173 ]

Analytics and Reporting

If the report is not saved it will open the save report dialogue box. Save it and continue. If the report is saved it will open the next page as seen in the following screenshot:

[ 174 ]

Chapter 6

Let us look in detail at the numbers marked on the screenshot above: 1. Select the user perspective on which the report will be run. The report will be filtered based on the data access to this user. If the user is at the top of the hierarchy and the recipients are below him in the hierarchy, they can view the data not accessible to them. Hence, we have to exercise caution when selecting the user so that we don't provide unauthorized access. 2. Select the appropriate users to e-mail this report to. If more than one user is in the delivery list or it is sent to a public group we need to save this report in the public folder where all the recipients will have access to it. 3. Select the date and schedule for the report. 4. Find the available options for the appropriate time. The time depends on other scheduled reports queued by other users. The exact time is also determined by the availability of bulk queues. 5. Save the schedule report. The report will run at the specified time and we will receive an e-mail containing the report.

Custom report types

The Custom 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 provides the administrators or users with manage custom report types to create custom report types such as standard report types. Users can create a report based on a custom report type once it is created. To setup a custom report type: 1. Navigate to Setup | App Setup | Create | Report Types and click on new Custom Report Type.

[ 175 ]

Analytics and Reporting

2. Define a custom report type by name, description, primary object, development status, and the category to store it in as shown in the following screenshot and click on Next.

3. Choose the objects for the custom report type. The objects are available based on the primary object's relationships to other objects. Only the objects with a lookup or master-child relationship with the primary object are seen in the list. Save the relationship.

[ 176 ]

Chapter 6

4. On the custom report type page layout related list click on the Edit Layout button as shown in the following screenshot:

5. On the edit layout we can specify which standard and custom fields a report can display when created or run from the custom report type. Once added select Preview Layout to check if the correct fields are added.

[ 177 ]

Analytics and Reporting

The custom record type will be available in the report type while creating reports.

Self study exercise – create a report

The general library needs to get an inventory check of all the media items available presently in the library and are scheduled to be returned by the end of the week. The availability of the item is determined by a checkbox check-out on the media object. The report should be grouped by the type of the media item (books or movies). Generate the report for the same. We have already seen how to create a report in the previous section. Refer to the section on report builder to create a report.

[ 178 ]

Chapter 6

Self study exercise – schedule the report

The librarian would like the report generated at the end of every working day and e-mailed to her. Please schedule the report prepared in the previous exercise to be e-mailed every day at 5 p.m.

Self study exercise – some more reports

The general library needs to generate a report of all the defaulters to display on their bulletin board. The report should contain the name of the defaulter, and the item the customer has borrowed. It should be grouped by the media resource (books and movies).

Displaying graphical charts using dashboards

Dashboards are the graphical representation of the reports. They can contain up to 20 components. They visualize the data of multiple reports on a single page. The dashboard can take a snapshot of the entire organization in a single view. They can also be scheduled for e-mail distribution.

[ 179 ]

Analytics and Reporting

Dashboard builder

The dashboard builder is the cloud utility to build stunning dashboards. It has easy to use drag-and-drop features.

On the left hand panel we can choose the type of available charts for creating a dashboard. The available options are: •

Bar Chart



Vertical Bar Chart



Line Chart



Pie Chart



Donut Chart



Funnel Chart



Gauge Meter



Tabular Chart

[ 180 ]

Chapter 6



Metric Chart



Visualforce Custom Chart Component

Using the Visualforce component we can extend the limits of the dashboard to many different possibilities. 1. A dashboard can have three columns at a time. The columns can be narrow, medium, or wide. To add graphs to the column simply drag the graph from the left hand panel on the column. 2. Data Sources are the reports and Visualforce Pages that provide the data to the graphs.

For a report to appear in the list, it should either be a Summary or Matrix report and grouped by at least one column. To add the data source to the chart, drag the data source over the chart we dragged in point 1.

[ 181 ]

Analytics and Reporting

3. Configuring the data point, once we add the data to the chart we can configure it to display values accordingly.

The Component Data tab allows us to group the data according to the summary fields on the object. We can also choose the target of the drill down on the dashboard, which is usually the report, the record object or a custom URL. Formatting options allow us to choose background gradients, text colors, and so on to make the chart more attractive. Some charts may also have special options.

[ 182 ]

Chapter 6

Combination charts

Combination charts plot multiple data in a single chart. Each set of data is based on a different field, so we can quickly and easily compare values in different charts. The sample combination chart is as shown in the following screenshot:

The options for combination charts include: •

Line chart on bar graph



Line chart on line chart



Bar graph on bar graph

Line charts can be normal or cumulative. Bar graphs can be horizontal or vertical.

Dashboard security

Unlike other Salesforce objects reports and dashboards do not follow the sharing rule and settings. The data on the dashboard created by a manager can be viewed by the subordinates if it is not kept in the correct folder.

Dashboard folder

To secure the data in the dashboard the most important thing is to create a folder shared with the proper people. Salesforce provides us with a My Personal Dashboard folder, which has sharing access to only one user. If we wish to create a separate dashboard for a group of users, we have to create a folder with correct sharing rights on it.

[ 183 ]

Analytics and Reporting

To create a dashboard folder, perform the following steps: 1. Go to the dashboard list view (Dashboard tab). 2. Select the Create new folder link on the top as shown in the following screenshot:

The dashboard list view will always open in the recent folder that was accessed. 3. On the pop-up screen, enter the relevant Dashboard Folder Label and select the access type.

[ 184 ]

Chapter 6

The access type can be Read Only and Read/Write. The third section lets us choose the relevant users for the folder. The folder if created as hidden from all users is only accessible to the user who created it. The third option lets us select specific users who can access the folder. 4. Fill in the details and save the folder. The folder can be seen in the tab list. Now if we save the dashboard in this new folder it will be shared with the users who have access to it.

Dashboard running user

The Running User of the dashboard is the user on whose perspective the data is displayed on the dashboard. For example, if the Running User is the manager, any user that can see the dashboard can see what the manager can see on it irrespective of the sharing rules. Alternatively, we can create a dynamic dashboard that changes the data according to the user who opens it. To create dynamic dashboards perform the following steps: 1. From the Dashboards tab, create a new dashboard or edit an existing one. 2. Click on the down arrow next to the View dashboard as field as shown in the following screenshot:

[ 185 ]

Analytics and Reporting

3. Select Run as logged-in user and click on OK. 4. Save the dashboard. The dashboard folder controls who sees the dashboard, while the runner user controls what is displayed on the dashboard.

Scheduling a dashboard refresh

We can also schedule for the dashboard to refresh at particular intervals. This feature is available only for EE and UE users.

To schedule a dashboard refresh: 1. On the Dashboards tab, select a dashboard using the View Dashboard field. 2. Click on Refresh and choose Schedule Refresh as shown in the following screenshot:

[ 186 ]

Chapter 6

3. The Schedule Refresh option will open another page as seen in the following screenshot:

[ 187 ]

Analytics and Reporting

The following steps correspond to numbers on the preceding screenshot: 1. Select the appropriate users to e-mail this report to. If more than one user is in the delivery list or it is sent to a public group we need to save this dashboard in the public folder where all the recipients will have access to it. 2. Select the frequency of scheduling the refresh, which can be daily, weekly or monthly. 3. Select the start and end date for the refresh. Find the available options for the appropriate time. The time is dependent on other scheduled dashboards queued by other users. If there is a dashboard scheduled to get refreshed at one time, the time won't be available to refresh again. 4. Click on Save. The dashboard will be delivered in the inbox at the refresh interval.

Self study exercise — create a dashboard

The general library wants to view their operation on a single dashboard. We have already created some reports in last exercise. Create a library dashboard with all the components for the users to access.

Analytic snapshot

An analytic snapshot is used to run a report on historical data. We can save tabular or summary report results to fields on a custom object, then map those fields to corresponding fields on a target object. We then schedule when to run the report to load the custom object's fields with the report's data. For example, the library manager can setup an analytic snapshot that reports on the books checkout every day at 5:00 p.m and store the data in a custom object. The library manager can then spot the trends in book issuing and the readership.

Setting up analytical snapshot

Before we setup an analytical snapshot we require two things: •

Source report: The source report is the custom report created by using the report builder. It can have columns of more than one object.

[ 188 ]

Chapter 6



Target object: The target object is the custom object that contains fields that are similar to columns in the report.

We need to make sure all the columns in the report map with the fields in the target object. The fields should be created on the target object. If you need help in setting up the report or the object, refer to the previous chapter. Once these two are in place, let us proceed to setup the analytical snapshot. 1. Go to User Name | Setup | Administration Setup | Data Management | Analytic Snapshots. 2. Click on New Analytic Snapshot and give it the appropriate name.

3. As shown in the screenshot, the data loaded in the object will be based on the sharing settings for the running user. 4. Select the target object and the source report, now click on Save and Edit Field Mappings. The mapping page allows us to map the fields from the report to the fields in the object. [ 189 ]

Analytics and Reporting

5. If the source report is a summary report select the level of grouping as shown in the following screenshot

6. Map the fields from the source report to the target object as shown in the following screenshot:

[ 190 ]

Chapter 6

7. Click on Edit on the Schedule Analytical Snapshot related list as shown in the following screenshot:

8. The scheduler is shown in the preceding screenshot, it is similar to the one used in reports and dashboards and has similar options hence won't be repeated again.

We can save the analytic snapshot any time we want while creating it. If the snapshot isn't scheduled it won't run. If accidently we save it while creating it, it can be scheduled from the snapshot page.

Now that we have a record of the historical data in the target object we can run the report on it, to analyze trends. [ 191 ]

Analytics and Reporting

Summary

In this chapter we have studied the analytics as a service offered by Salesforce. We now can create reports and dashboards that suit our needs. We can analyze trends using the analytic snapshot. We can setup dashboards to visualize the entire company data on a single page. In the coming chapter we will be entering the last phase of setting up a Salesforce organization, we will be creating users and designing applications for multiple users.

Test your knowledge

1. A manager wants to share specific fields of data with his subordinates that only he has access to. What is the best way to share specific fields of data? Please select two choices. a. Select the view dashboard as with his own name b. Folder permission on a report c. Run report as scheduled reports and e-mail distribution d. Folder permission on a dashboard

2. What are the features of a custom report type? Please select two items. a. Define object relationships and fields for reports b. Define anti-join relationships c. Create analytic snapshot reports d. Define up to four object relationships 3. A developer needs to create a trending report what should he/she use to get the historical data? a. Reports b. Analytic snapshots c. Roll-up summary d. Report types e. Audit history records

[ 192 ]

Chapter 6

4. An application was designed without considering requirements for reports and dashboards. Which of the following statements is TRUE? a. The data model will support all the requirements of the application including reports and dashboards b. Reports are part of the application and the application design will take care of it. c. No special considerations for reports or dashboards are required as Salesforce can natively take care of the requirements. d. The data model and the application will not cater for reports and dashboards 5. Dashboard refresh can be monitored using: a. Apex jobs b. Scheduled jobs c. Dashboard jobs d. Report jobs 6. Which component in a dashboard gives you a grand total? (Select any two) a. Table b. Gauge c. Chart d. Metric 7. What is the best type of dashboard component to display a list of your top 10 customers? a. Metric b. Table c. Gauge d. Chart

[ 193 ]

Application Administration In the first four chapters, we have seen the MVC architecture of Force.com. Then we learned the security model of the Force.com application. We also explored the analytics part provided by the service. The MVC model helps us separate the business logic from the display and data. In this chapter we will be completing the journey to build a complete application using point-and-click by learning the administrative capabilities of Force.com. We will be covering the following points in this chapter: •

Managing access control



Overview of Force.com licenses



Restricting data access



Understanding actors



Understanding the security pyramid



Managing profiles



Setting up roles



Sharing settings

This chapter explains the functional aspect of building a Force.com application and the things to consider before developing the application. Let's begin.

Managing access control

Before we build any enterprise application we must first consider the users who will be using the application. In any business organization there are many users who will be using many different aspect of the Force.com application.

Application Administration

For example, in a big enterprise application, there will be service centre users who use cases and solution objects regularly. They should not be able to access opportunity objects. Similarly, the account leaders do not need access to all cases, but only cases for their account. In the Library Management System, the librarian has complete access to the entire library database, but the clerks who are dealing with check-in and checkout do not need to access the books table to modify. There should also be a consideration as to which users can customize this application and what parts of the systems they should be given access to customize. To summarize, we need to think of the following factors before starting to develop the application on Force.com: •

Which users will be using what parts of the application?



Is there sensitive data that need special privileges?



Is there any data restriction, such as should peers see each other's data?



Who are the power users who can customize this app? What level of customization can we provide for the app?

Force.com licenses

The access to applications and features is determined by user licenses and the feature licenses of the application. For access to the CRM application Salesforce.com we require Salesforce licenses. For Force.com, there are separate platform licenses. To determine how many licenses are left with your organization, perform the following steps: 1. Go to Setup | Administration Setup | Company Profile | Company Information. 2. Below the company profile in the related list, the number of licenses available for use is shown in the following screenshot:

[ 196 ]

Chapter 7

We can use the license to provide access to the application, for example, we need a Salesforce license for the user to access the CRM objects such as accounts, opportunities, and so on. User licenses are consumed when we apply them to the user Profile. Only the administrator can apply the user licenses to the user profile. To apply the user licenses use the following steps: 1. Go to Setup | Administration Setup | Manage Users | Users. 2. Create new user or edit an existing user. A user once created cannot be deleted. We can only make a user active or inactive. Creating an active user consumes a user license, which is directly linked to the billing of Salesforce usage. It is recommended that you practice this in a dev org. Please consult your administrator if you are creating a new user in production org.

[ 197 ]

Application Administration

3. Select the user license from the drop-down as shown in the following screenshot:

If we are giving access to the custom object build on Force.com and not the entire CRM application we can give the Salesforce platform license.

Types of licenses

Depending on the type of license we get access to the different objects on Force.com. The following table summarizes the use of licenses. Features

Salesforce

CRM objects Chatter Custom Apps AppExchange Apps

Yes Yes Yes Yes

Salesforce platform No Yes Yes Yes

Force.com free

Chatter

No Yes Yes- Only one custom app is allowed.

No Yes No No

The Salesforce platform license is used for deploying a custom app for users on Force.com. The best license to access multiple Force.com apps is the Salesforce platform license.

[ 198 ]

Chapter 7

Feature licenses

Apart from the user license Salesforce also provides us with feature licenses to enable us to use different types of features. Most of these feature licenses come bundled with the CRM user licenses, however, additional licenses can be purchased from Salesforce. To determine how many feature licenses are left with your organization, perform the following steps: 1. Go to Setup | Administration Setup | Company Profile | Company Information. 2. Below the Company Profile in the related list, the number of feature licenses available for use is shown in the following screenshot:

Feature licenses are used to access the special features of Salesforce application. A user can utilize more than one feature license. Since summer 2010, the Salesforce CRM content user feature license has been included in all organizations at no additional cost.

Using queues to balance workloads

User profiles are associated with a single user; we can also create work queues with multiple users that can be associated with the record. We can create queues for the object and add multiple users to them. We can assign queues for the approval process or workflow alerts. Records remain in queue until a user accepts them they are transferred from the queue. Any member in the same queue has the same access to all the records in the queue.

[ 199 ]

Application Administration

To create a custom object queue: 1. Navigate to User Name | Setup | Administration Setup | Manage Users | Queues.

2. Give an appropriate queue name. 3. Select the objects that can be owned by the queue. 4. We can individually assign users to the queue or even public groups. All the users get ownership access if the record is owned by the queue.

Localization with translation workbench

By default Salesforce fully supports 16 languages and 15 end-user languages. We can easily translate the entire app in one of the supporting languages, however, if we need to localize the app in a custom language not available in the list, we use the translation workbench to manually translate it. The Translation Workbench lets us specify languages we want to translate, assign translators to languages, create translations for an app, and override labels and translations from managed packages. Everything from custom picklist values to custom fields can be translated in the language.

[ 200 ]

Chapter 7

To open the Translation Workbench go to User name | Setup | Administration Setup | Translation Workbench as shown in the following screenshot:

Setting up translation workbench

To begin with the translation workbench we first need to enable it. Enabling the workbench makes some significant changes in the organization. Once we enable the workbench the following changes occur. We cannot mass edit picklist values; however, we can mass add new values. When picklist values are sorted alphabetically, they are done according to the primary language of the organization. Translation workbench only helps translate the constant data such as labels, static picklist values; the user entered data is NOT translated. To enable the translation workbench, perform the following steps: 1. Go to User name | Setup | Administration Setup | Translation Workbench | Translation Settings. 2. The page will display the basic warning and general info with the Enable button at the bottom as shown in the following screenshot:

[ 201 ]

Application Administration

3. Once we enable the workbench on the settings page, we find another option to add a new language. Click on the Add button to add new languages.

4. We can select the Language from the list of languages and the user to associate with the language as shown in the following screenshot:

5. If the user associated with the language has the View Setup and Configuration option in their profile they can also help translate the application in their language.

[ 202 ]

Chapter 7

Restricting data access

The most crucial part of any enterprise-level application (built on Salesforce or otherwise) is the control of data. The litmus test for effectiveness of an enterpriselevel application is the way we restrict unauthorized access to data. The following diagram illustrates the record sharing in an organization:

[ 203 ]

Application Administration

The four records A, B, C, D are evenly distributed between the reps and the manager. Rep 1 should only see record A, Rep 2 should only see record B, and so on. On the top of the chain, the Super Manager can see all the records under him. Before designing the application we first need to consider the stake holders of the application: •

Who will be using the application?



What will these users do?



Is the data sensitive or critical?



Who will be customizing the application?



Are there any global records that should not be edited by the users?



Which set of users will be editing which data?

These are some of the questions that need to be addressed before we understand the security model of the application.

Exercise – defining actors

Let us go back to the problem statement of the Library Management System. The purpose of this exercise is to determine the actors in the system. Let us have a recap of the Library Management System. What objects do we have so far? Library Management System Object name

Related to (relationship)

Comments

Media

CustomerMedia (detail object of media)

The media object is the master table to store the collection of media. Books and videos are separated by record type to show different types of media.

Customer

CustomerMedia (detail object of customer)

The Customer object stores the customer information. It also stores the total fine paid by the customer as a roll-up field.

Book Penalty (detail object of member)

[ 204 ]

Chapter 7

Object name

Related to (relationship)

Comments

CustomerMedia

Customer, Media (master object)

The CustomerMedia object stores the customer and media in a junction object and is used during the checkout and check-in function of the library management.

Book Penalty

Customer

This is a child object on customer and stores the amount of late fees paid to the customer.

Let us keep our library system very simple. There are two types of users who will be using this application: 1. Librarian(s): They will be responsible for the check-in and checkout of the books. They will be responsible for collecting penalties from the customers. 2. Admin: Admin will be updating the book catalogue and adding new members to the library.

Exercise – creating the CRUD diagram

Based on the above information, prepare the matrix diagram for record sharing in the library system. The easiest way to prepare a matrix diagram is to draw a table with object information on the X axis horizontal and user information on the Y axis on the left. In every column check the access the users will need to perform the task. The basic access rights are called CRUD, which is an abbreviation of Create, Read, Update, and Delete.

The matrix diagram for the Library Management System is shown below:

[ 205 ]

Application Administration

The matrix diagram is important while designing the Force.com application. In the next chapter we will be seeing the different ways of restricting access to users and separating the data. We need to have the matrix diagram ready so that we can prevent unauthorized access to the data.

Security pyramid

The security of Force.com model is split into four parts: 1. Organization wide default 2. Profile and role-based sharing 3. Sharing rules 4. Manual sharing The four types of sharing can be visualized as a reverse pyramid with the maximum number of people accessing the data increasing as we move above in the pyramid, as shown in the following diagram:

Let us climb on top of the pyramid one by one and look at the different types of security offered by Force.com. [ 206 ]

Chapter 7

At any level, we can extend the sharing of the record to other users. An important point to note will be, at no level can we restrict the record from the user, if he can access it using the bottom-most rules.

For example, if a user sees a record due to Organization Wide defaults and profiles, there is no way we can restrict him from seeing the using Sharing Rules or Manual Sharing. However, if the user cannot access the object due to Organization Wide defaults, we can make it visible using the Sharing Rules or Manual Sharing.

User security

As we have already seen in Chapter 1, Getting Started with Force.com that users need the combination of user name + password + IP address or security token to login to any Force.com application. As with any multiple-users based system the most important aspect is not what the user sees, but what the user should not see. Once the user is authenticated using any of the combinations mentioned above, the level of user is determined. If the user has certain restrictions or special privileges, the data is displayed accordingly. The restrictions and privileges are stored by the system administrator in the Profile. The system administrator is usually the first user created by Force.com. The profile of system administration has full access over the system and it is always recommended to have a minimum set of administrators.

Based on the permission set in the profile associated with the user, the data, application and logic is displayed. By default, Salesforce provides us with six standard profiles. These six profiles cannot be modified; if we wish to change some permission in any of them, we clone the profile and modify the clone: 1. System administrator 2. Authenticated website user 3. Standard platform user 4. Force.com user 5. Contract manager 6. Standard user Let us create a user and assign him a profile. [ 207 ]

Application Administration

Exercise – creating a user

The library management system is now in place and users can't wait to try it out. Create a user with a Standard User profile so that he/she can access the system. 1. To create a user go to Username | Setup | Administration Setup | Manage Users |Users. 2. Click on New User, as shown in the following screenshot:

Alternatively if this is the first instance of the organization, we can add multiple users at a time. 3. The Add New User page is self-explanatory; we will look into the important aspects of it only. As shown in the figure, assign the profile of the Standard User to the profile.

[ 208 ]

Chapter 7

Profiles are directly associated with the license type. The standard user profile and the other six user profiles are available as part of Salesforce licenses.

4. The checkboxes on the right determine the functionality and other desktop applications used by the user. For instance, if the user is allowed to access Salesforce from a mobile application, please select Mobile User. Similarly, if the user can access the service cloud console select service user. 5. Fill in the contact information for the user. The contact information is like any other user information. The user can change it later himself. 6. Locale settings determine the language and the time zone for the user when he/she logs in. 7. Finally, if the user is to be notified there is a separate checkbox at the bottom of the page. If the user is created for testing purposes, there shouldn't be a need to notify the user at the time. Checking this box will send the user a temporary one-time expiry password, which the user has to change at the first login.

8. Save the record. There is one important step skipped purposely in the form, which is adding of the role, which we will see in the coming sections.

Password policies

Another important step in user security settings is the password policy for the users. Password policies help maintain a strict and complex pattern in password with the automatic expiry. By default Salesforce passwords expire in 90 days and the user cannot use three previous passwords. They are 8 characters in length and should be a combination of alpha-numeric characters. These policies can be changed using the Password Policies settings. [ 209 ]

Application Administration

To change the Password Policies perform the following steps: 1. Go to User name | Setup | Administration Setup | Security Controls | Password Policies. 2. Change the policies according to the requirements as shown in the following screenshot:

3. The message and help link can be provided to the users in case they forget the password. If the system administrator forgets the password we can reset it using the reset link sent to the e-mail.

Roles and profiles

The security of the system depends on how the data is shared with the users and how to prevent access to the unauthorized user. Roles and profiles together determine how the data is accessed by the actors in the system. The role determines what data the user can accesses, while the profile determines all things the user can do with the data. Let us explore these two things in more detail. [ 210 ]

Chapter 7

Understanding profiles

A profile contains information on what the user should see and what he can do in the force.com application. The profiles control the following things: •

What apps the user can see



What tabs the users are permitted to use



What objects can the user operate on and what CRUD-level permission is given to them



The profile also determines the default RecordType and the default page layout available for the user



Fields can be enabled or restricted for the profile



What Apex class and Visualforce codes are accessible for the user



The profile also determines the hours in which the user logs in as well as the IP restriction



What all system-level configurations are the users permitted to change is also controlled by the profile

Creating a custom profile

Force.com limits editing of the standard profile hence it is recommended to create a custom profile for special permission-set users. In this section we will be creating a custom profile for the librarian. In contact manager, group, and professional edition organizations, we cannot create custom profiles or edit standard profiles. In enterprise, unlimited, and developer edition organizations we can create, edit, and delete custom profiles.

To create a profile, perform the following steps: 1. Go to Username | Setup | Administration Setup | Manage Users | Profiles. 2. Click on the New button. 3. We need to select the base standard or existing custom profile to clone the new one. This will copy the existing permissions to the new one. 4. The new profile page is very large so let's look at it section wise.

[ 211 ]

Application Administration

5. The first section as shown in the next screenshot is the Custom App Settings. It allows us to select which applications the user can see. Depending upon the apps loaded in your system, it might look like the following screenshot:

6. The next section is Tab Settings where we choose what tabs the user is going to see as shown in the following screenshot:

There are three options we can choose for the tab settings. Default On

Makes the tab default to the user when he opens the app

Default Off

Hides the tab from the user but the user can personalize his app to add the tab again.

Tab Hidden

Hides the tab from the user and the user cannot add it.

If there are some sensitive tabs containing the important data, the tab has to be specifically hidden from the user. The user can personalize his app and add new tabs to it as well. It is always recommended therefore to hide the tab separately along with the app. 7. Administration Permissions determine the administrative capabilities of user in the Force.com app. General User Permissions are usually the data.

[ 212 ]

Chapter 7

8. There are different permissions available in the General User Permissions and the Administration Permissions category. The entire list of permissions is available at: https://login.salesforce.com/help/doc/en/admin_userperms.htm

9. As shown in the following screenshot Standard and Custom Object permissions are the CRUD permissions we can give to all the standard and custom objects in the Force.com org. These permissions determine what access control the user has on the object specified. The View All and Modify All checkbox makes the object visible and sharable regardless of any other sharing settings.

10. Save the profile. Thus we can now create a custom profile. The profile determines what data can be seen by the user. Now let us see how the user should see the data using roles.

Assigning roles

Roles are created according to the corporate hierarchy of the system. Roles determine how the data is shared with the user. While profiles determine what objects can be seen by which users, roles determine which records from the object can be seen by the user. The user can be separated on the basis of their work department, territory, or company hierarchy.

[ 213 ]

Application Administration

The following diagram illustrates a basic sample role hierarchy:

As seen in the diagram A, B, C, and D are records of the same objects owned by Rep1, Rep2, Rep3, and Rep4 respectively. While all the four reps have access to the same objects, they do not have access to each other's records. Manager 1 can see the data and reports from Rep1 and Rep2 as they come under his hierarchy. He cannot, however, access the data for Rep3 and Rep4. The Super Manager can see the entire organizations data as he is topmost in the hierarchy. Role hierarchy prevents the data being seen by people at the same level in the hierarchy, at the same time it grants full access to the people on top of the hierarchy. In the above example, Manager 1 will get all access to the Rep1 data. To achieve this we set up a role hierarchy.

[ 214 ]

Chapter 7

Steps to set up role hierarchy

Use the following steps to set up role hierarchy: 1. Go to Username | Setup | Administration setup | Manage Users |Roles. 2. If it is your first time it will show a splash page for roles with the button Set Up Roles. Click on the button to proceed. 3. As shown in the next screenshot, the default view is the tree view for the roles. The view can be changed in the upper right hand corner to normal view or list view.

4. As shown in the screenshot, with the link Add Roles, we can create roles at any level in the hierarchy. 5. Once we define the role, using the Assign link, we can assign users to the role. In the next section we will deal with the object-based security in Salesforce and understand the significance of role hierarchy in distributing the records.

Exercise – scaling the Library Management System

The general library now wishes to install this system across multiple locations. They have branches in the east coast as well as the west coast.

[ 215 ]

Application Administration

The structure of the organization is as follows: • •

They have a separate head librarian for every coast who in turn gets reports from multiple sub-librarians Each branch has a clerk who handles the check-in and checkout of books and maintains the customer profiles

Organization-Wide defaults

While roles and profiles are used to determine the user-based security, the organization wide default determines the distribution of data with the user. We use the defaults in the object to determine which people across the role hierarchy can access which objects. Objects allowed to be viewed by the organization wide defaults can be restricted using profiles and roles.

To set up Organization Wide defaults, follow the steps: 1. Go to Username | Setup | Administrative Setup | Security Controls | Sharing Settings as shown in the following screenshot:

2. As shown in the screenshot the general sharing diagram for the organization will be displayed: [ 216 ]

Chapter 7

3. Select the object to configure for the organization wide tabs. We get three options to choose from as shown in the following screenshot:

The following options determine the sharing settings of the object: Private

The role hierarchy is observed and people cannot view their peer records. In the figure above, Rep1 cannot see the data for Rep2 in the object that has private settings

Public Read Only

This is useful if we have master data that the people refer to for example, the books info in the library. They can be kept public read only. In this case everyone across the hierarchy can see the data

Publix Read/ Write

This option does not obey any role hierarchy and anyone can edit/ modify or even delete the objects depending on their profile permissions.

[ 217 ]

Application Administration

Organization-wide default summarized

To set up organization-wide defaults follow the simple method: •

First find out which user requires least access to an object. Set the organization-wide default to all the objects based on this user. For example, the library clerk is the person in a library who mostly handles the issuing and the return of the books. He needs the least access on the customer object (assuming that only the librarian can handle membership) set the customer object to private read only.



Most restrictive record access is defined using a organization-wide default. Access to additional records is made available through the role hierarchy, sharing rules, and manual sharing.



Changing organization-wide default settings can delete manual sharing if that sharing is no longer needed.

Permission sets

A new addition to the profile-based permission is the permission sets. A user can have only one profile at a time with a static set of permission. With the new permission sets, we can create a separate set of permissions for the uses. For example, to give access to an object, instead of modifying the profile we can create a permission set and assign it to user. This is a new feature that will be updated in winter 2012.

Sharing rules

Sharing rules are the special sets of privileges set by the administrator to automatically grant record access to certain users or the group of users. There is a limit of 100 owner-based sharing rules. Sharing rules can allow the records for the user, which are restricted by the roles. However, if the object is not visible to the user profile, the records cannot be made visible by sharing rules. Sharing rules are one-off sharing options for complex sharing logic that cannot fit in the normal sharing structure.

[ 218 ]

Chapter 7

Let us set up the sharing rules: 1. Go to Username | Setup | Administrative Setup | Security Control | Sharing Settings. 2. Below the organization wide defaults there are multiple sections of objects as shown in the following screenshot:

3. We can set the sharing rules based on criteria or the users as shown in the following screenshot:

[ 219 ]

Application Administration

Some standard objects such as leads have different sharing settings.

4. In Step 1, we can choose the sharing based on record owner or based on criteria. 5. In Step 2, if it is Criteria as seen in the preceding screenshot, select the Criteria. The rules are same as formula fields. 6. In Step 3, select the users to share the records and finally specify the access levels.

Manual sharing

Finally, the last option in sharing is the manual sharing option given to the individual users with full access to a record. It is used if the organization wide defaults access for the object is set to Private. This is generally done by a record owner, for a single record. Only the record owner and users above the owner in the role hierarchy are granted full access to the record. It is not possible to grant other users full access. Users with the Modify All object-level permission for the given object or the Modify All Data permission can also manually share a record. User-managed sharing is removed when the record owner changes or when the access granted in the sharing does not grant additional access beyond the object's organization-wide sharing default access level.

Quick bites

Sharing can be a bit complex because we need to fix the complex business problems using different tools, so here is a quick guide to understand sharing •

The owner of the record can view/edit/modify and delete the record



If the organization uses sharing and security, the person above the owner can also view/ edit the record



If it is any object having sharing settings public read/write or greater it can be seen/edited



If the record is private, a user can access it only when there is a sharing rule giving him the access or if it is manually shared

[ 220 ]

Chapter 7

Setting up security

Keep the following points in mind while setting up security: •

First consider the user who has least possible visibility of the objects. Set up the organization wide defaults based on them.



Then, prepare the matrix for the users who have access to other objects. Prepare their profiles and permission sets based on that.



Finally, set up the role hierarchies to enable mutual sharing of the objects.



The remaining odd records can be shared using sharing rules.

Summary

In this chapter we saw the security of the Force.com application. We now understand the difference between the difference Force.com licenses. We have seen how to make the matrix sheet before designing the application. We have climbed the sharing pyramid and understood how users are granted sharing access. With this chapter we come to the end of application development on the cloud-based Force.com platform. We now know how to build applications on Force.com without using code. We can create objects, make pages for them and also solve business problems using clicks. Using the powerful logic as a service we can now manage to migrate the approval processes and workflows trigger on the cloud. By now your sample Library Management System should be ready.

Test your knowledge

1. A company wishes to deploy a custom build application on Force.com platform, what license would the users need access the application? (Choose any that apply) a. Chatter b. Salesforce platform c. Salesforce d. Force.com free edition

[ 221 ]

Application Administration

2. A company is using Chatter for their internal communication. They wish to give a user access to the account object. If he is a Chatter user what things should be done to give him access? a. Assign a separate profile for him b. Make the normal user his manager c. It cannot be done 3. The users with the Salesforce platform license can access the CRM application. a. True b. False 4. If the actors who will be using the applications are not determined before the creation of application, which of the following will happen? Select any two choices. a. We will be unable to create reports and dashboards b. Unauthorized users can access sensitive data c. There will be no room for scaling the application to large users 5. The library needs to make all records of an object visible to all users when it is in 'Approved' status. The records are created with 'New' status and are only visible to a select set of users. How will a user implement this? a. Set the object level sharing to private, add a workflow rule to update the sharing rule when status changes b. Set the object level sharing to public read-only; restrict the sharing when status is 'New' c. Set the object level sharing to private, create a public group with appropriate users, modify manual sharing to public group based on status d. Create role hierarchy, modify the user profiles when status changes

[ 222 ]

Exam Guide and Practice Paper We have covered all the topics on Force.com that are part of the Salesforce Certified Developer Exam. This chapter covers the basic FAQs about the exam and the questions. •

Overview of the exam



Certification and maintenance releases



Sample paper



Additional resources

This is a brief chapter to give an overview of the exam and help you mentally prepare for what is coming.

Overview of the Salesforce Certified Developer Exam

The Salesforce Certified Developer Exam is a multiple choice question exam. The exam consists of 60 questions to be completed in 90 minutes. The pass score for the exam is 68 percent so roughly at least 40 questions should be answered correctly. The exam is proctored and no reference material should be referred to while sitting the exam. The questions in the exam are multiple choice and multi-select. When there is more than one correct answer, it is specified in the question itself. For example, Choose any 2, Choose any 3.

Exam Guide and Practice Paper

Anyone with good knowledge of the Salesforce.com and Force.com platform can appear for the exam. Salesforce also has DEV401 classroom training for the same. More information on DEV401 can be found at http://certification.Salesforce.com/Developers. Once you finish the exam, the result is conveyed instantly on the screen. The result shows only a pass or fail and the Developer Certificate is delivered through an e-mail. No grades or percentages are displayed on the result.

Certification maintenance and releases

Once the exam has been taken, the candidate has to complete release-specific Developer Exams every three months (roughly). The release-specific exams are additional questions that cover the upgrades to Force.com in the releases. Only the upgrades on the topic part of Salesforce Certified Developer Exam syllabus are part of the exam. Release exams are published three times a year for each of the Force.com upgrades released throughout the year. The candidate can sit for two release exams along with the Certification exam. An annual maintenance fee of $100 is charged to the candidate, which includes three release exams. SalesForce.com Certified professionals are notified automatically when new release training material and exams become available.

Sample paper

The sample question paper given here is similar to the Salesforce Certified Developer Exam. This paper is given so that the candidate can practice the time management for the paper. Set a timer for 90 minutes and answer the following paper: 1. What is the maximum number of Master-Detail relationships that can be created on a custom object? a. 1 b. 2 c. 4 d. Unlimited

[ 224 ]

Chapter 8

2. An organization has decided to manage hiring and positions. A custom object has been created to manage all new job positions. All positions below $50,000 must be approved by the hiring manager, and positions above $50,000 must be approved by the hiring manager and the regional hiring manager. What would a developer use to declaratively fulfill the requirement? a. Apex code, to check the position's salary and assign the appropriate resource for approval b. Approval process c. Validation rules d. Dynamic routing approval 3 If a developer has created a junction object what is the significance of the first Master-Detail (primary) relationship? a. Look and feel, the junction object's detail and edit pages use the color and any associated icon of the primary master object b. You cannot delete the primary relationship c. You cannot rename the primary relationship d. There is no significance 4. An organization has created a custom object to manage all job positions. Using an approval process they have configured the application to have the first step of the process require approvals from three different hiring managers. Select the two (2) possible approval choices based on multiple approvers for an approval step. a. Approve or reject based on the first response b. Require unanimous approval from all selected approvers c. Require majority approval from all selected approvers d. Require x out of y approval from all selected approvers 5. Which of the following is NOT a step in creating a junction object? a. Creating the custom object to serve as the junction object between the two master objects b. Creating two Master-Detail relationships c. Customizing the related lists on the page layouts of the two master objects d. Creating two lookup relationships [ 225 ]

Exam Guide and Practice Paper

6. When a record has been rejected by all approvers, Salesforce executes all final rejection actions. Which of the following is NOT a possible final rejection action? a. b. c. d.

Lock the record from being edited Send an e-mail to a designated recipient Delete the record Update a field on the record

7. Which of the following cannot be used on a user page layout? Please select two choices. a. Tag b. c. d. e.

Links Buttons Custom fields Inline Visualforce

8. An organization wants to use custom objects to track bugs. The organization wants the ability to link related bugs to parent bugs in a parent-child relationship. What type of relationship should be used? a. b. c. d.

Master-Detail Self Hierarchically Many-to-many

9. An organization wants to use the import wizard to import different types of data. What type of data cannot be imported through the wizard? a. b. c. d.

Accounts and contacts Leads Custom objects Users

10. An organization is interested in using the data loader to load data into Salesforce.com. Which of the following are NOT capabilities of the data loader? Please select two (2) choices. a. b. c. d.

Import greater than 50,000 records Import data into two objects in a single transaction Rollback import transactions Run by command line [ 226 ]

Chapter 8

11. An organization needs the ability to view the value of the opportunity stage field on an opportunity product related list. Please choose the declarative method of fulfilling the requirement. a. Create an Apex method to replicate the value on the child object, and set the field level security to read-only and expose the new field on the opportunity product related list b. Create a cross object formula field on the opportunity product object and expose the formula field on the opportunity product related list c. Create a validation rule on the opportunity product object d. Create a new picklist field called stage on the opportunity product object, and expose the field on the opportunity product related list 12. A developer wants to use the console to view the parent object of the child object in focus on the console. How would a developer specify what related list fields are displayed on the parent object? a. On an child object's mini-page layout b. On an parent object's mini-page layout related lists field selection c. On the parent object's page layout related lists field selection d. You cannot modify the related fields on the console view 13. An organization has two custom objects to track job positions and salaries for those positions. Everyone in the organization should be able to view the positions, however, only select users can view the salary records. What steps should a developer take to ensure the requirement is fulfilled? a. Create a lookup relationship between positions and salaries; define public access on position and private access on salary b. Create a Master-Detail relationship between positions and salaries; define public access on position and private access on salary c. Create a Master-Detail relationship between positions and salaries; define private access on position and create sharing rules on salary d. Create a lookup relationship between positions and salaries; define public access on position and public access on salary; create sharing rules on salary to restrict visibility

[ 227 ]

Exam Guide and Practice Paper

14. A developer has created a custom field marked as an external id on an object. If two records in the object have the same external id, and an upsert action occurred for that same external ID what would happen? a. The first matching external ID record would be updated b. Both matching external ID records would be updated c. A new record is created d. An error would be reported 15. A developer has a requirement to collect the state and the cities for the state selected on an account page layout. Once the user selects a state, only the possible cities in that state should be available for entry. What is the best declarative method for fulfilling this requirement? a. Create a workflow rule that will update the city once a state is entered b. Create a validation rule that will cause an error if the city is not in the state that has been entered c. Create a dependent picklist for cities based on the state that has been entered d. Create a formula field that look ups the valid cities for the state entered 16. A developer has created an approval process. What would require that a formula entry criterion be used versus standard criteria? a. User profile evaluates to system administrator b. Determine if the record is newly created c. Determine if a record has been updated d. Determine if a field has been changed 17. The HR managers want to see the position and the best candidates that match the position. What is the best method to fulfill the requirement? a. Add an inline Visualforce page on the job position page layout b. Add the candidate related list to the job position page layout c. Create a validation rule on the job position page layout d. Create a formula field on the job position object and add to the page layout

[ 228 ]

Chapter 8

18. Which of the following is not a process or data type of application? Which of the following applications CANNOT be made using the Force.com platform? a. Time entry application b. Inventory management c. Word processing d. Human resource management 19. Which two (2) items most closely relate to the view layer of the model view controller paradigm? a. Page layout b. Validation rule c. Custom tab d. Custom field 20. In which Salesforce instances would there be identical record IDs? a. Production; full sandbox b. Production; full sandbox; Apex sandbox c. Production; full sandbox; config only sandbox; Apex sandbox d. Salesforce.com never repeats record IDs 21. A developer has created a time-based workflow that escalates a lead record 10 days after it has been created if no updates have occurred. What is the best way for the developer to test that the new time based workflow rule is functioning? Please select two (2) choices. a. Use debug logs to set up the developer; create a new lead record review debug logs b. Create a new lead record; view the time-based workflow queue; c. Set up the developer for time-based workflow queue; create a new lead record; view the time-based workflow queue d. Create a new lead record; view the outbound messages queue 22. What settings can you specify on a profile? Please select two (2) choices. a. Revoke sharing permissions b. Enable record types c. Enable create read, create, edit, and delete objects d. Specify language [ 229 ]

Exam Guide and Practice Paper

23. A manager in an organization wants to share specific fields of data with his subordinates that only he has access to. What is the best way to share specific fields of data? Please select two (2) choices. a. Run as on dashboards b. Folder permission on a report c. Run as on scheduled reports d. Folder permission on a dashboard 24. Under what circumstances would the sharing button be enabled on a detail view for a record? a. A developer has added the button to the page layout b. When record sharing is enabled in the user profile c. When record sharing is set to public, read only, or private for the object d. When record sharing is set to public read/write for the object 25. When creating a sharing rule, what entities can data be shared to? Please select three (3) choices. a. Public groups b. Users c. Roles d. Roles and subordinates e. Queues 26. A developer needs to make a field that is normally accessible to most users inaccessible on the report wizard for specific users. What is the best method to fulfill that requirement? a. Field-level security b. Remove the field from the page layout c. Remove the field from the user profile d. Change my display under personal settings

[ 230 ]

Chapter 8

27. What can be done with report summary totals? Please select two (2) choices. a. Calculate values from a previous report b. Calculations based on report summary totals c. Highlight outliers d. Historical analysis 28. If a parent object has a lookup relationship defined with a child object, what happens to the child object when you delete a record from the parent? a. The child record is deleted b. Nothing c. The parent record cannot be deleted d. The child record cannot be deleted 29. How can a developer get a custom object added to the quick create list? a. Add the object through home page component settings b. It is added automatically c. Expose a custom tab for the custom object d. Enable the quick create on the user profile 30. Select the features that are available through custom report types. Please select two (2) items. a. Define object relationships and fields for reports b. Define up to 4 object relationships c. Define anti-join relationships d. Create analytic snapshot reports 31. An organization wishes to have everyone view/edit records on an object except for a single person x who should only have read-only access to the object. What is the best way to implement the requirement? a. Modify the sharing access for the object to public read/write and remove user x from the role hierarchy b. Modify the sharing access for the object to private and remove user x from the role hierarchy c. Modify the sharing access for the object to public read only, create a public group with everyone except user x; create a sharing rule and define read/write access to the public group. d. Modify the page layout to be read-only [ 231 ]

Exam Guide and Practice Paper

32. Using a formula field how would a developer calculate the number of days since a record has been created? The CreatedDate field is a DateTime type field. a. TODAY() – DATEVALUE(CreatedDate) b. NOW() – DATEVALUE(CreatedDate) c. TODAY() – CreatedDate d. CreatedDate – TODAY() 33. Salesforce.com has notified you that they have enabled the ability to update audit fields for your organization. When inserting a record which field can you set? a. CreatedDate b. IsDeleted c. SysModStamp d. UpdatedDate 34. A developer needs to create a trending report. What should he/she use to get the historical data? a. Reports b. Analytic snapshots c. Roll-up summary d. Report types e. Audit history records 35. What is the best type of dashboard component to display a list of your top 10 customers? a. Metric b. Table c. Gauge d. Chart 36. Select the Salesforce.com edition that is NOT available today. a. Professional b. Unlimited c. Enterprise d. Premium [ 232 ]

Chapter 8

37. Using the Force.com platform declarative model to build an application, which of the following do you NOT have to do? Please select three (3) choices. a. Install a database server b. Configure an application using clicks not code c. Deploy a web server d. Administer and e-mail server 38. An organization wants to create a field to store manager data on the user object. The manager field is a reference to another user record. What type of relationship should be used? a. Master-Detail b. Hierarchical c. Lookup d. Many-to-many 39. What are the data types that are supported by a formula field? Please select three (3) choices. a. Text b. Percent c. E-mail d. Currency e. Phone 40. What is true about a junction object? a. A custom object that has two Master-Detail relationships b. A custom object that has a Master-Detail relationship c. A standard object that has two Master-Detail relationships d. A standard object that has a Master-Detail relationship 41. What is true about a cross-object formula field for a Master-Detail relationship? a. You can only create a cross-object formula field on the parent object b. You can only create a cross-object formula field on the child object c. You can create a cross-object formula field on both the parent and child object d. A cross-object formula field is not available for a Master-Detail relationship [ 233 ]

Exam Guide and Practice Paper

42. When you create a custom tab for a custom object, what are the features that are available by default? Please select two (2) choices. a. Sidebar search object b. Custom reporting c. Quick create d. Ability to track activity 43. What are the different custom tabs that you can create? Please select three (3) choices. a. Web tab b. Apex tab c. Visualforce tab d. Custom object tab e. Standard object tab 44. For the order management application, the developer has created a custom object to store the product line and product combination. When creating an order, the product line and product combination need to be consistent. What is the best option for implementing this? a. Use a workflow to update the product automatically based on the product line b. Create a validation rule using IF c. Create a formula field to enforce the combination d. Create a validation rule using VLOOKUP 45. What is true about a Master-Detail relationship? Please select two (2) choices. a. When the parent record has been deleted, all the child records will be deleted b. You can have a child record without the parent record c. You have to expose the master lookup field on the child detail page layout d. You cannot delete a child record

[ 234 ]

Chapter 8

46. How does Salesforce enforce data access using role hierarchy? a. Users are given access to the records owned by the users who are below them in the role hierarchy b. Users are given access to the records owned by the users who share the same role in the role hierarchy c. Users are given access to the records accessible by the users who are below them in the role hierarchy d. Users are given access to the records accessible by the users who are above the role hierarchy 47. What will cause the analytic snapshots run to fail? Please select three (3) choices. a. The source report has been deleted b. The target object has a trigger on it c. The running user has been inactivated d. The target object is a custom object e. The source report is saved as matrix report 48. What are the components belong to the model of the model-view-controller design paradigm? Please select three (3) choices. a. Custom relationship b. Custom page layout c. Custom object d. Custom field e. Workflow rules 49. Where do you change the hover detail? a. Mini view b. Page layout c. Profile d. Mini page layout 50. What layer of model-view-controller paradigm are standard or custom objects associated with? a. View b. Model c. Controller d. View and controller [ 235 ]

Exam Guide and Practice Paper

51. What is a junction object? a. Object with lookup relationship b. Master detail relationship c. Object with two lookup relationships d. Object with two Master-Detail relationships 52. What field can be controlled by a translation workbench? a. Rule criteria b. Formula c. Validation errors d. Assignment rules 53. In a Master-Detail relationship, what happens when the a record is deleted from the parent object? a. Parent record alone gets deleted b. Exception occurs c. Parent and child record will not be deleted d. All child records are deleted 54. In a recruiting application, salary is a child object to a parent position object via a Master-Detail relationship The min pay and max pay fields of salary object cannot be modified when the Position status on the parent is 'Approve'. How would a developer design this? a. Create a Visualforce component on the position detail page b. Rollup-summary field c. Validation rule on position object d. Formula field on the salary object e. Validation rule on the salary object 55. Object X has a lookup to object Y. Which of the following statements are TRUE? Please choose two (2). a. Fields of both X and Y are accessible from object Y b. Fields of object Y can be accessed from object X c. Fields of both Y and X are accessible from object X d. Fields of object X can be accessed from object Y [ 236 ]

Chapter 8

56. In Master-Detail relationship scenario the fields of the parent object need to be displayed in the related list. How will a developer design this? a. Cross-object formula field b. Workflow rule c. Validation rule d. Assignment rule 57. What are the components of the dashboard that use grand totals? Please choose two (2) items. a. Chart b. Metric c. Table d. Gauge 58. Universal containers need to make all records of an object visible to all users when it is in 'Approve' status. The records are created with "New" status and are only visible to a select set of users. How will a developer implement this? a. Set the object level sharing to private, add a workflow rule to update the sharing rule when status changes. b. Set the object level sharing to public read-only, restrict the sharing when status is New. c. Set the object level sharing to private, create a public group with appropriate users, modify manual sharing to public group based on status d. Create role hierarchy, modify the user profiles when status changes 59. In a master-child relationship between a standard object and custom object which of the following statements is NOT true? Please select two (2) items. a. The standard object is always the master b. The custom object is always the master c. The custom object is always a child d. The standard or custom object can be a master e. The standard object is never a child

[ 237 ]

Exam Guide and Practice Paper

60. A customer has a requirement to filter columns in the related list. As a developer how will you accomplish this? a. Use the filter option in the related list section of the page layout b. Use the filter option in the related list section of the mini page layout c. Use the filter option in the detail page layout of the related list object d. Build a Visualforce component with a filter to replace the related list section of the page layout 61. How do you highlight totals in a report? a. Roll-up summary field b. Formula field c. Custom summary field d. Summary totals 62. A recruiting application has a position object that contains location, department and other information relating to a position. We need to create a report that is grouped by department but not by locations. What is the best type of report a developer would choose? a. Summary report b. Tabular report c. Matrix report d. A report using Visualforce 63. In a recruiting application a position that is of type critical should not be kept open for more than 14 days. How will you develop the business logic to cater to this? a. Time-dependant workflow action to send an e-mail to the owner after 14 days b. Time-dependant workflow action to send the record for review to owner after 14 days c. Time-dependant workflow action to send an e-mail to the owner before 14 days d. Time-dependant workflow action to close the position after 14 days

[ 238 ]

Chapter 8

64. A job application object has a child review object to store candidate reviews. The review needs to be tracked between a score of 1 to 5. The score has to be a choice between 1 and 5 displayed as a radio button. How will a developer cater to this requirement? a. Create 5 fields for scores (1 to 5) of type radio-button and use it in review page layout b. Create a dependent picklist that feeds the radio button type field c. Create a formula field d. Create a Visualforce page with radio buttons for the review object 65. An application was designed without considering whether requirements for reports include dashboards. Out of the following statements which one is TRUE? a. The data model will support all the requirements of the application, including reports and dashboards b. Reports are part of the application and application design will take care of it c. No special considerations for reports or dashboards are required as Salesforce can natively take care of the requirements d. The data model and the application will not cater for reports and dashboards 66. In a data model object A is related to B, B is related to C. How will a developer create a report to include fields of A and C? a. Create lookup relationships between A,B and C b. Create a custom report type with A, B and C, and use it in the report c. Create a custom report with A and C fields as relationships already exist d. Report cannot be created

Additional resources

We hope you have fared well in the exam above. This section lists some good official and community blogs, podcast videos that will provide even more information on the Certification exam. The best way to find more resources is to Google them.

[ 239 ]

Exam Guide and Practice Paper

Official Salesforce resources

The Developer Force blog is the primary resource of all things Force.com. http://blogs.developerforce.com/

The Certification Home contains all information about Salesforce certification exams. http://certification.Salesforce.com/Home

The Developer Certification Home contains all information about classroom training of DEV401 and a guide for the Salesforce Certified Developer Exam. http://certification.Salesforce.com/Developers

Force.com Books contains additional books, workbooks, cookbooks about creating applications on Force.com. http://wiki.developerForce.com/page/Force.com_Books

Community resources

ForceCertified is a free resource for Force.com Certification by John Coppedge. http://forcecertified.com

ForcePrepare is a good site for preparation on the Certification exam. It also has a mock test to solve. http://www.forceprepare.com/

This small guide contains tips about the Force.com exam.

http://mysalesforcecode.blogspot.com/2009/03/developer-401-forcecomexam-tips.html

The iTunes podcast is a free and the most important of the materials available online. It contains videos of the DEV401 classroom trainings. http://itunes.apple.com/podcast/Salesforce.com-trainingcertification/id325668840

The SalesforceChannel hosts all the videos about Salesforce, and Webinars. They have a good section on Developer Training videos. http://salesforcechannel.com/pages/developer-training

[ 240 ]

Chapter 8

Summary

Every journey has an end, and thus we have reached the end of the book. We have covered all the topics that will help you to become a Salesforce Certified Developer. For further reading you can visit some of the community resources provided in the previous section. Some of the best help is available on the Salesforce forums or by using #AskForce on Twitter. All the best for your exam. May the Force be with you.

[ 241 ]

Sample Paper Answers 1.

b) 2

2.

b) Approval process

3.

a) Look and feel, the junction object's detail and edit pages use the color and any associated icon of the primary master object

4.

a) Approve or reject based on the first response



b) Require unanimous approval from all selected approvers

5.

d) Creating two lookup relationships

6.

c)

7.

a) Tags



c)

8.

b) Self

9.

d) Users

Delete the record Buttons

10. b) Import data into two objects in a single transaction

c)

Rollback import transactions

11. b) Create a cross object formula field on the opportunity product object and expose the formula field on the opportunity product related list 12. b) On a parent object's mini-page layout related lists field selection 13. a) Create a lookup relationship between positions and salaries; define public access on position and private access on salary 14. d)

An error would be reported

15. c)

Create a dependent pick list for cities based on the state that has been entered

16. d) Determine if a field has been changed

Sample Paper Answers

17. a) Add an inline Visualforce page on the job position page layout 18. c)

Word processing

19. a) Page layout

c)

Custom tab

20. a) Production; full sandbox 21. a) Use debug logs to set up the developer; create a new lead record; review debug logs

b) Create a new lead record; view the time-based workflow queue

22. b) Enable record types

c)

Enable create read, create, edit, and delete objects

23. a) Run as on dashboards

c)

24. c)

Run as on scheduled reports When record sharing is set to public read only or private for the object

25. a) Public groups

c)

Roles



d) Roles and subordinates

26. a) Field level security 27. b) Calculations based on report summary totals

c)

Highlight outliers

28. b) Nothing 29. c)

Expose a custom tab for the custom object

30. a) Define object relationships and fields for reports

b) Define up to four object relationships

31. c)

Modify the sharing access for the object to public read only, create a public group with everyone except user x; create a sharing rule and define read/write access to the public group

32. a) TODAY() – DATEVALUE(CreatedDate) 33. a) CreatedDate 34. b) Analytic snapshots 35. b) Table [ 244 ]

Appendix A

36. b) Unlimited 37. a) Install a database server

c)

Deploy a web server



d) Administer and e-mail server

38. b) Hierarchical 39. a) Text

b) Percent



d) Currency

40. a) A custom object that has two Master-Detail relationships 41. b) You can only create a cross-object formula field on the child object 42. a) Sidebar search object

c)

Quick create

43. a) Web tab

c)

Visualforce tab



d) Custom object tab

44. d) Create a validation rule using VLOOKUP 45. a) When the parent record has been deleted, all the child records will be deleted

c)

You have to expose the master lookup field on the child detail page layout

46. a) Users are given access to the records owned by the users who are below the role hierarchy 47. a) The source report has been deleted

b) The target object has a trigger on it



c)

The running user has been inactivated

48. a) Custom relationship

c)

Custom object



d) Custom field

49. d) Mini page layout 50. b) Model [ 245 ]

Sample Paper Answers

51. d) Object with two Master-Detail relationships 52. c)

Validation errors

53. d) All child records are deleted. 54. e) Validation rule on the salary object 55. b) Fields of object Y can be accessed from object X

c)

56. c)

Fields of both Y and X are accessible from Object X Validation rule

57. b) Metric

d) Gauge

58. c)

Set the object level sharing to private, create a public group with appropriate users, modify manual sharing to public group based on status

59. c)

Custom object is always a child



d) Standard or custom object can be a master

60. d) Build a Visualforce component with a filter to replace the related list section of the page layout 61. d) Summary totals 62. a) Summary report 63. b) Time-dependant workflow action to send the record for review to owner after 14 days 64. d) Create Visualforce page with radio buttons for review object 65. d) The data model and the application will not cater for reports and dashboards 66. b) Create a Custom Report type with A, B, and C, and use it in the report

[ 246 ]

Chapter-wise Solutions Chapter 1 1. 2. 3. 4. 5. 6. 7.

b, c a b a, c, d a, b a, b a

Chapter 2

1. c, d Lookup cannot be made universally required. Use Master-Detail 2. b,c,d,e 3. b A user with 'view encrypted data' permission can still edit the field. 4. a 5. a,b,e 6. e 7. b 8. d 9. b 10. a

Chapter-wise Solutions

Chapter 3 1. a, c, d, e 2. a,c 3. a,c 4. a, d 5. a 6. a,b 7. c 8. c 9. a,c,d

Chapter 4 1. c

Formula fields calculations cannot be seen in debug log 2. b,c,d 3. a 4. a, d 5. a 6. c 7. a,c 8. a, c 9. b 10. a 11. a 12. c

Chapter 5 1. a, b, e 2. c 3. a [ 248 ]

Appendix B

Note: We can upsert using external id, question asks for update) 4. b It was a tricky question, data model can be modified only using setup, data loader loads data 5. b 6. d 7. a

Chapter 6 1. a, b 2. a, d 3. b 4. d 5. b 6. b,d 7. b

Chapter 7 1. b, c, d 2. c 3. b 4. b, c 5. c

[ 249 ]

Index Symbols , layout components 83, 84 , layout components 82 , layout components 84 , layout components 84 -help command password encryption, Encrypt.bat used 152

A access control managing 195, 196 Add condition button 146 Add Roles link 215 AES (Advanced Encryption Standard) algorithm 48 AJAX, in Visualforce about 88 88 88 88 88 88 components 88 analytical snapshots about 188 setting up 189, 191 setup, prerequisites 188 apex data loader data loader, troubleshooting 154 data, upserting 146-149 downloading 144 salient features 143 setting up 150, 151

using 144 using, through command line 151 versus, cloud-based data import wizard 154 Apex Data Loader, using through command line command-line data loader, configuring 152 password encryption, encrypt.bat used 153 process-conf.xml file, preparing 152, 153 using 151 API_Access 143 application mini page layout 74 application types, Force.com content centric applications 22 data centric applications 22 developing, on Force.com 22 process centric applications 22 transaction centric applications 22 approval actions approved 117 finally approved 117 finally rejected 117 recall action 118 rejected 117 submitted 117 approval process workflow, comparing 120 Assign link 215 authentication, on Force.com about 26 e-mail address, changing 26, 27 security tokens, resetting 28 trusted IP addresses, adding 27, 28 automated approval process approval actions 117-119

approval steps, creating 116 multi-step approval process, creating 114, 115 parallel approval step 119, 120 using, for productivity increase 113

B basic rules, Business Logic implementation approval process entry rules 95 cross object formula fields 101 formula fields 98 roll up summary fields 104 syntax 94, 95 syntax, components 95 validation rules 95, 96 validation rules, creating 97, 98 workflow rules 95 Bean attribute 153 Blank Space adding 68 screenshot 67 Business Logic implementing, basic rules 93 Business Logic implementation basic rules 93 business processes automation e-mail, sending to members 107-110 workflow, using 106

C category, logs Apex Code 124 Apex Profiling 124 callout 123 database 123 System 124 validation 123 Visualforce 124 workflow 123 Cloud-based data import wizard using 140-143 versus, Apex data loader 154

Cloud Computing model, Force.com about 10 automatic upgrades feature 10 multi-tenant architecture feature 10 scalability feature 11 subscription model feature 11 upgrades and maintenance feature 11 combination charts about 183 options 183 controller extensions 77 controllers about 76 controller extensions 77 custom controllers 77 standard controllers 76 Standard List controller 78 cross object formula fields about 101 penalty, calculating 101-104 CRUD commands about 137 External IDs 138, 139 Upsert 138 CSV (Comma Separated Value) format 143 custom button about 69 creating 70, 71 Detail Page Button type 69, 70 Detail Page Link type 69 List View Button type 70 custom controllers 77 custom reports types, matrix 165 types, setting up 175-178 types, summary 165 types, tabular reports 165 custom tabs blank spaces 67 custom buttons 69 field options 72 links 69 other layouts, editing 72, 73 sections 67

[ 252 ]

D dashboard builder about 180-182 options 180 dashboards dashboard builder 180 refresh, scheduling 186-188 running user 185, 186 security 183 using, for graphical chart display 179, 180 data access actors, defining 204, 205 controlling 203, 204 CRUD diagram, creating 205 problem sharing 220 profiles 210 roles 210 security pyramid 206, 207 user security 207 dataAccess.type property 153 data binding in Visualforce 78 data components, Salesforce standard components 85 85 data loading tools about 139 Apex data loader 143 Cloud-based data import wizard 139 data management operations basics 129 data, deleting 130 data export 130 data, inserting 130 data, updating 130 data manipulation wizards about 155 records, mass deleting 158, 159 records, mass transferring 155-157 data storage limit 159 data-types, Force.com Checkbox field 45 currency fields 45 custom fields 41 E-mail field 45

field options 45, 46 phone field 45 picklists 42 text fields 41 debug logs setting up 122 using 124 declarative development about 23 best practice 24 delegated approval process 117 DeveloperForce.com about 28 uses 29 development, on Force.com declarative development 23 declarative development, MVC components 23 developer account, creating 25 programmatic development 24 programmatic development, MVC component 23

E Email field 41 encrypt.bat Encrypt text command 154 Generate a key command 154 using, for password encryption 154 Verify encrypted text command 154

F field options encrypted field 47 encrypted field, limitations 48 encrypted fields, creating 48 External ID 46 External ID, benefits 46 required field 45 unique field 46 fields 40 Force.com application development, prerequisites 196 application types 22 authentication 26 Cloud Computing model 10 [ 253 ]

database, creating 33 data-types 40 Eclipse Force.com IDE 19, 20 Force.com Metadata 19 Force.com platform 12 Metadata 18, 19 Metadata API 19 model 11 MVC architecture 13 Online PageEditor 19, 20 overview 9 licenses 196 MVC architecture 129 Force.com Metadata 18 Force.com platform development 18 key technology 14 formula fields about 98 return date, calculating 99, 100

J

G

layout components 82 83, 84 84 84 library management system about 33 basic E-R diagram 34 requirements 34 Library Management System data model, building, creating 52 licenses, Force.com about 196, 197 applying 197, 198 feature license 199 types, accessing 198 links about 69 creating 70, 71 log files sdl.log 154 sdl_out.log 154 log levels, in system log console DEBUG 124 ERROR 124 FINE 124 FINER 124

graphical charts displaying, dashboards used 179, 180

I inline Visualforce about 89 on page layouts 89 page 89 static resources 90 input components, Salesforce standard components about 86 87 87 85 87 87 87 87 87 87 ipconfig command 27

Junction object creating 52

K key components, Visualforce controllers 76 pages 76 standard components 76 key technology, Force.com platform Apex 15, 16 AppExchange 17 Force.com Metadata 15 Force.com Sites 17 Force.com Webservice API 15 multitenant kernel 14, 15

L

[ 254 ]

FINEST 124 INFO 124 WARN 124 logs category 123 level, in system log console 124 types 121-123 logs, types debug logs 122 system logs 123 Lookup relationship about 49 properties 49

M manual sharing 220 Master-Detail relationship about 50 properties 50, 51 Media object 135 Metadata API 19 mini page layout about 74 creating 74, 75 model view controller. See  MVC architecture MVC architecture about 13 diagram 13

N Name property 152

O object about 35 creating 36, 37 structure 36 types, custom object 36 types, standard object 35 wizard, fields 38-40 organization wide defaults about 216 private setting 217 public read only setting 217

publix read/write setting 217 setting up 216-218 output components, Salesforce standard components 85 85 85 85

P page layout editor creating, with Cloud Based Editor 68 features 67 using 67 page layouts inline Visualforce 89 permission sets 218 Picklists 42 process debugging 121 logs, types 121 monitoring 121 Process Bean 152 process.mappingFile property 153 process.operation property 153 profiles about 210, 211 actions, controlling 211 creating 211-213 permission sets 218 tab settings, options 212 programmatic development 24

Q queues using, for workload balancing 199, 200

R record IDs 15 character IDs 130 18 character IDs 130 about 132, 133 importance 130 Salesforce URL 133, 134 summarizing 134 [ 255 ]

URL format, exploring 131, 132 recordSetVar attribute 78 relationship about 49, 135, 136 Lookup relationship 49 many-to-many relationships 51, 52 Master-Detail relationship 50 modifiable system fields, features 137 Self-relationship 51 system fields, modifying 136 report builder about 168 overview 168-172 reports about 163 creating 165-167 creating, report builder 168 options 173 using, for tabular data display 164, 165 roles about 210 assigning 213 hierarchy 214 hierarchy setup, steps 215 library management system 215 roll up summary fields about 104 creating 104, 106 functions 104 Running User, dashboard 185

S Salesforce Object Query Language. See  SOQL Salesforce server connecting, through API 137 Salesforce server, connecting through API about 137 CRUD commands 137 data migration, from legacy system 139 Salesforce standard components 85 85 about 85 data components 85

input components 86, 87 output components 85 sandbox about 19 configuring 21 developer sandbox 21 full copy sandbox 22 sections adding 68 screenshot 67 security setting up 221 security, dashboards about 183 folder, creating 183-185 security pyramid about 206 sharing types 206 sfdc.entity property 153 sfdc.password property 153 sfdc.username property 153 sharing rules about 218 setting up 219, 220 SOQL 15 standard controllers 76, 77 Standard List controller 78 system logs 123

T tabular data displaying, reports used 164, 165 text field about 41 Picklists 42 types 42 time-dependent workflow about 111 diagram 111 member, blacklisting 111, 112 multiple time-based trigger, creating 113 Transfer button 157 translation workbench opening 201 setting up 201-203 using 200 [ 256 ]

U Upsert command 138 user security about 208, 209 password policies 209, 210

V validation rules about 95, 96 creating 97, 98 View Setup and Configuration option 202 Visualforce AJAX 88 Component library 81 content 75 data binding 78 JavaScript 88 key components 76 overview 75 pages, using in organization 79 tags 79

Visualforce Component library about 81 layout components 82-84 other layout components 84 Visualforce pages Buttons and Links 79 tag library 79 using 79 Visualforce tags about 79 binding, with data 80 types, action binding 81 types, data binding 80

W workflow actions 110 approval process, comparing 120 creating 107-109 time-dependent workflow 111 using, for business processes automation 106

[ 257 ]

Thank you for buying

Force.com Developer Certification Handbook (DEV401) About Packt Publishing

Packt, pronounced 'packed', published its first book "Mastering phpMyAdmin for Effective MySQL Management" in April 2004 and subsequently continued to specialize in publishing highly focused books on specific technologies and solutions. Our books and publications share the experiences of your fellow IT professionals in adapting and customizing today's systems, applications, and frameworks. Our solution based books give you the knowledge and power to customize the software and technologies you're using to get the job done. Packt books are more specific and less general than the IT books you have seen in the past. Our unique business model allows us to bring you more focused information, giving you more of what you need to know, and less of what you don't. Packt is a modern, yet unique publishing company, which focuses on producing quality, cutting-edge books for communities of developers, administrators, and newbies alike. For more information, please visit our website: www.packtpub.com.

About Packt Enterprise

In 2010, Packt launched two new brands, Packt Enterprise and Packt Open Source, in order to continue its focus on specialization. This book is part of the Packt Enterprise brand, home to books published on enterprise software – software created by major vendors, including (but not limited to) IBM, Microsoft and Oracle, often for use in other corporations. Its titles will offer information relevant to a range of users of this software, including administrators, developers, architects, and end users.

Writing for Packt

We welcome all inquiries from people who are interested in authoring. Book proposals should be sent to [email protected]. If your book idea is still at an early stage and you would like to discuss it first before writing a formal book proposal, contact us; one of our commissioning editors will get in touch with you. We're not just looking for published authors; if you have strong technical skills but no writing experience, our experienced editors can help you develop a writing career, or simply get some additional reward for your expertise.

Salesforce CRM: The Definitive Admin Handbook ISBN: 978-1-84968-306-7

Paperback: 376 pages

A comprehensive, power-packed guide for all Salesforce Administrators covering everything from setup and configuration, to the customization of Salesforce CRM 1.

Get to grips with tips, tricks, best-practice administration principles, and critical design considerations for setting up and customizing Salesforce CRM with this book and e-book

2.

Master the mechanisms for controlling access to, and the quality of, data and information sharing

3.

Take advantage of the only guide with real-world business scenarios for Salesforce CRM

OCA Oracle Database 11g: SQL Fundamentals I: A Real World Certification Guide ISBN: 978-1-84968-364-7

Paperback: 460 pages

Ace the 1Z0-051 SQL Fundamentals I exam and become a successful DBA by learning how SQL concepts work in the real world 1.

Successfully clear the first stepping stone towards attaining the Oracle Certified Associate Certification on Oracle Database 11g

2.

This book uses a real world example-driven approach that is easy to understand and makes engaging

3.

Complete coverage of the prescribed syllabus

Please check www.PacktPub.com for information on our titles

Microsoft Forefront UAG 2010 Administrator's Handbook ISBN: 978-1-84968-162-9

Paperback: 484 pages

Take full command of Microsoft Forefront Unified Access Gateway to secure your business applications and provide dynamic remote access with DirectAccess 1.

Maximize your business results by fully understanding how to plan your UAG integration

2.

Consistently be ahead of the game by taking control of your server with backup and advanced monitoring

3.

An essential tutorial for new users and a great resource for veterans

4.

Uncover the advantages and ease of use of Direct Access, the latest VPN technology from Microsoft

OpenAM

ISBN: 978-1-84951-022-6

Paperback: 292 pages

Written and tested with OpenAM Snapshot 9—the Single Sign-On (SSO) tool for securing your web applications in a fast and easy way 1.

The first and the only book that focuses on implementing Single Sign-On using OpenAM

2.

Learn how to use OpenAM quickly and efficiently to protect your web applications with the help of this easy-to-grasp guide

3.

Written by Indira Thangasamy, core team member of the OpenSSO project from which OpenAM is derived

Please check www.PacktPub.com for information on our titles