Learning Force.com Application Development

By Chamil Madusanka
  • Instant online access to over 7,500+ books and videos
  • Constantly updated with 100+ new titles each month
  • Breadth and depth in over 1,000+ technologies
  1. Getting Started with Force.com

About this book

Starting with an introduction to the Force.com model, key features, and advantages of the Force.com platform, this book delves into the design and development of applications on the Force.com platform. Particular emphasis is given to building the data model and user interfaces of the Force.com application, designing the Force.com application for multiple users, and protecting data related to your application.

This book also covers the most important features of the Force.com platform such as preserving data quality with validation rules, automating the business process by using workflows and approval processes, data management operations and tools, reports and dashboards, e-mail service related features of the Force.com platform, and deploying a Force.com application. Through the course of the book, you will learn not only declarative (point-click) developments, but also programmatic developments such as building custom pages using Visualforce and custom coding using Apex. By the end of the book, you will have learned about the Force.com tools including the Force.com IDE and standard Visualforce components that are used to develop build Visualforce pages.

Publication date:
April 2015
Publisher
Packt
Pages
406
ISBN
9781782172796

 

Chapter 1. Getting Started with Force.com

Cloud computing has made significant changes to the IT/software development industry. Cloud platforms are one of the important components of cloud computing. Cloud platforms allow developers to develop apps and run them on the Cloud, including platforms to build on-demand applications and platforms as a service (PaaS). Salesforce.com has introduced the first on-demand platform called Force.com.

This chapter introduces the Force.com platform and explains designing and developing applications on the Force.com platform. The sample application scenario and Entity Relationship Diagram (ERD) will be introduced at the end of this chapter. This chapter covers the following topics:

  • Introduction to the Force.com platform

  • Designing and developing applications on the Force.com platform

  • Identifying building blocks of the Force.com platform

  • The sample application

 

Introduction to the Force.com platform


Salesforce.com established the company as a Customer Relationship Management (CRM) product vender in 1999. The Force.com platform, which is known as Salesforce.com's platform as a service (PaaS) product, was launched in 2007. Force.com is a cloud computing platform that allows for developers to quickly build, share, and run custom business applications over the Internet. When we are developing applications on the Force.com platform, we don't need any additional hardware, additional software, and configuration and maintenance (database and hardware) efforts. The Force.com platform provides three default application categories, which include applications of Salesforce.com CRM. The main categories are as follows;

  • Sales cloud: This is for the automated Sales processes of an organization. For example, from campaign management to lead capture and account to quote management, you can do everything related to Sales here. Sales cloud can be used for marketing, leads, opportunities, and maintaining new customers (Accounts and Contacts).

  • Service cloud: This is used for any kind of support application such as call center, customer support desk, and so on. It helps the organization to manage their support on the cloud.

  • Chatter: This is the collaboration tool of Salesforce CRM. It helps the organization to integrate back office work in to Salesforce.

The Force.com platform runs on Salesforce.com's infrastructures with the main architecture called multitenant architecture. For more details about multitenancy, read the Key features of Force.com platform subsection. The multitenant architecture allows us to build custom applications without purchasing hardware and software licenses and without having to worry about database maintenance. It provides a trusted, configurable and customizable, upgradable, able to integrate, and a secure platform to build our custom applications on.

Understanding the Force.com model

In traditional software development, we need to manage additional software and hardware, software licenses, networks, database configurations, and maintenance by ourselves. However, the Force.com platform provides these additional features in their cloud computing model. We need to pay only for the things we use, not for all the hardware and software. That's because we get the Force.com platform as a service.

The architecture of the Force.com platform

The preceding figure shows the overview of the Force.com platform. The following table shows you the difference between the traditional platform and the Force.com platform.

Traditional Platform

Force.com Platform

Supply the core services of Database access

Form builder (build complete and standard UIs)

Supply Containers for logic

Process builder

Supply Containers for presentation

Logic and presentation as a service (Apex and Visualforce for custom developments)

Need to use other software to create our app

Fully functional reporting and analytical tools

Additional components to run the data center

Security

All of this will end up with additional expenditure

Sharing model

 

Workflow and approvals

 

Full support for the integrations with existing systems

 

Full support for mobile devices

 

Can access the platform through a web browser

Key features of the Force.com platform

The following are the key features of the Force.com platform:

  • Multitenancy

  • Application services

  • Force.com metadata

  • MVC architecture

  • Programming language

  • Integration

  • Force.com sites

  • AppExchange

Multitenancy

Multitenancy is the major technology of the Force.com cloud platform. It is used to share the IT resources in a secure and cost-effective way. Let's consider a real-world example to understand the multitenancy. Let's think about a luxury apartment complex with some facilities such as a playground, a swimming pool, and a gymnasium. This apartment complex has multiple owners. Everyone owns a separate apartment and every owner uses the shared playground, the shared swimming pool, and the shared gymnasium. These facilities are equal to a single, shared stack of hardware and software. The apartment is equal to the instance of a single client (a tenant). Therefore, a client has their own apartment with shared facilities and privacy.

The multitenant architecture

There are some advantages of multitenancy, which are as follows:

  • User satisfaction

  • Cost reduction

  • Automatic upgrades

  • No maintenance

  • Enhanced quality

  • User retention

  • Application providers can reach the hosted application

  • Application providers can gather some information (such as errors and performance issues) of the application, which will be helpful to make further enhancements

  • An error can be incurred from a particular tenant, but the solutions will be received by all the users who use the application

Application services

In traditional software development projects, we have to build or integrate various additional support applications such as login, validations, e-mail functions, reporting, UI, testing, and integrations. You had to repeatedly build these kinds of additional support applications in different projects. The Force.com platform provides the majority of support applications, which are most commonly needed in developing today's business application. For example, the Force.com platform has various features to automate your business process such as reporting, workflow and approvals, e-mail, user authentication, and integrations. These services are common to many software projects. Therefore, we can build applications with more functionality and within a short time period.

Force.com metadata

With multitenancy, we get secure, fast, reliable, customizable, and upgradable applications. When it comes to custom extensions by multiple tenants, we need to track and keep tenant-specific customizations without affecting the core application. The metadata-driven architecture takes care of that. After multitenancy, metadata-driven architecture is the second most important architecture in the Force.com platform. All the configuration, customization, and coding in the Force.com platform are defined and available as XML. It can be extracted and imported via a set of web services. Simply, metadata is data about data. The metadata-driven model provides the following advantages:

  • Complex applications can be created by only using point-click developments (without any coding).

  • A developer can build the application with the end user experience but the elements of the application are automatically translated to the metadata at creation time.

  • Metadata provides a speedy development.

  • Customization and extensions can be done without affecting the end user.

  • Metadata can be used to construct an identical environment to use in another organization.

  • Metadata can be used to assist version controlling.

  • Metadata can be used for testing and troubleshooting by comparing multiple environments.

    The metadata architecture of Force.com

The preceding figure shows the metadata-driven architecture of Force.com. It creates the separation between the runtime engine, the application data, and metadata. The polymorphic application includes database tables, relationships, UI elements, pages, classes, and so on.

MVC architecture

The Force.com platform uses the Model View Controller (MVC) architectural pattern for developing an application:

  • Model: This defines the structure of the data. In Force.com, objects define the data model. Salesforce has designed the platform by mapping every entity to some object.

  • View: This defines how the data is represented. In Force.com, page layouts and Visualforce pages come under this category.

  • Controller: This defines the business logic. The rules and actions which manipulate the data control the view. In Force.com, apex classes, triggers, workflows, approvals, and validation rules are under this category.

Programming language

The Force.com platform provides its own set of programming language, mark-up language, query language, and search language.

Apex

Apex, the world's first on-demand language is considered as the programming language of the Force.com platform. Apex is object oriented and the syntax is similar to Java and C#. It allows developers to build the logic with the interaction of existing platform features. According to the MVC architecture, Apex falls into the controller because it is used to write the controller classes and triggers on the Force.com platform. Apex can be used to:

  • Create custom controllers/Controller extensions

  • Create triggers that are executed automatically in records such as insert, update, delete and undelete particular objects

  • Access and invoke external web services

  • Create batch jobs

Visualforce

Visualforce is an implementation of MVC architecture. In the Force.com platform, we can develop Force.com applications with custom objects and standard objects. Every object has a standard user interface with one or more page layouts. But we cannot use standard page layouts for complex requirements. Here, Visualforce comes into play.

Visualforce is a web-based user interface framework, which can be used to build complex, attractive, and dynamic custom UIs. Visualforce allows the developer to use standard web development technologies such as jQuery, JavaScript, CSS, and HTML5. Therefore, we can build rich UIs for any app, including mobile apps. We'll be discussing Visualforce with standard web development technologies and Visualforce for mobile in more depth later. Similar to HTML, the Visualforce framework includes a tag-based markup language.

SOQL

Salesforce Object Query Language (SOQL) allows us to fetch data from Saleforce objects. SOQL syntax is similar to SQL but simpler. For example, SOQL has the SELECT keyword but doesn't contain the INSERT or UPDATE keywords. It is different from SQL as SOQL doesn't have the JOIN keyword. SOQL can be used in Apex code and it provides a powerful feature to manipulate and process data in Apex code.

Tip

Salesforce objects are similar to database tables. This will be explained in the next couple of chapters.

SOSL

Salesforce Object Search Language (SOSL) allows us to search your organization's data from Salesforce objects by specifying a text expression, scope of field to search, list of objects and fields to retrieve, and conditions to select rows in the source objects.

Tip

SOQL is used to fetch data from a single object and SOSL is used to fetch data from multiple objects. More about SOSL and SOQL will be discussed in Chapter 7, Custom Coding with Apex.

Integration

The Force.com platform provides the facility to integrate with existing applications. There are various advantages of integrating, such as including external systems into our processes, syncing data from multiple sources, and accessing data in other systems. Using an open Simple Object Access Protocol (SOAP) web service, the Force.com API provides access to all the data stored in the application. There are integration benefits as follows:

  • By using Force.com technologies, it takes less time to integrate than traditional integrations

  • The Force.com platform-based API provides direct and low-level access to Salesforce application data and metadata

  • There are many options to choose integration technologies and solutions that fit into their existing system

  • Proven platform and integration

Force.com sites

Force.com sites allow us to create public sites using Salesforce.com data, Visualforce, and standard web technologies such as CSS, JavaScript, and jQuery. Force.com sites are directly integrated with the Salesforce organization and it doesn't require a user authentication using the Salesforce username and password. A Force.com site has the following features and benefits:

  • Data from selected organizations can be exposed to the public through your own domain URL

  • There are no integration issues because Force.com sites are hosted on Salesforce servers

  • It can be built using Visualforce pages

  • According to the requirement, you can enable or disable the user registration

AppExchange

With the preceding features, you can build different kinds of applications. But how can you publish and distribute these applications? AppExchange will do it for you. AppExchange is the place to submit your developed applications, which can be directly installed in the client's organization.

AppExchange—the destination for CRM and Force.com apps

Advantages of Force.com

When we use Force.com platform to build enterprise applications instead of traditional software development, we will gain the following advantages:

  • We don't need to buy, install, maintain, and configure hardware and software.

  • We can start customizations as soon as we buy the organization and user license.

  • We can rapidly build and customize the applications on the Force.com platform.

  • The Force.com platform has a simplified development model because it uses multitenant and metadata-driven architecture.

  • It has the feature of instant scalability.

  • Quarterly upgrades of Salesforce.com do not require any maintenance from the user.

  • We can use or build multiple applications on a single platform. This is dependent on which Salesforce edition you are using. In Salesforce, the limitations change from edition to edition.

  • This is a proven platform for business-critical applications.

  • The Force.com platform is more secure and reliable. To learn more about security and trust visit http://trust.salesforce.com/.

 

Designing and developing applications on the Force.com platform


Before you start development on the Force.com platform, you have to do some ground work and have to learn about the data orientation of the Force.com platform, suitability of the application for the Force.com platform, the nature of the data underlying that application, and design the application for the Force.com application.

Signing up for a free developer edition account

The Force.com platform provides the development environments, tools, resources, and documentation, which can be used to develop applications. The Force.com tools will be described in Appendix A, Force.com tools. When we talk about development environments, free developer edition (DE) environment is the best option to develop with the latest technologies such as the Apex programming language, Visualforce markup language, and web services API.

Tip

DE is free, and you can use it for learning purposes, although it comes with certain limitations.

Follow the steps to create a free developer account:

  1. Go to https://developer.salesforce.com/.

  2. Click on Signup.

    The developerforce web page

  3. Then, you will get the following page and fill all the fields in the form.

    The registration page

    Tip

    Select a unique username in the form of an e-mail by which you will access your developer edition account. Salesforce allows you to select a unique name by default. If you select any pre-existing username, you will get an error.

  4. Click on Sign me up.

  5. An e-mail will be received including the link to specify your login credentials

Basic application design

When we design and build an application on the Force.com platform, we need to be aware of the data that we are going to process underneath the application. Good data design and good development practices can produce flexible and efficient applications.

Types of applications suitable for Force.com

We cannot use the Force.com platform for any kind of application development. Therefore, we need to understand the apps that are better suited for the Force.com platform. There are four types of applications that are required to automate an enterprise process, which are as follows:

  • Data-Centric Apps: Data-centric applications are the ones that have powerful databases. They are based on the structure and consistency data such as in database or XML files. They are centered on a database and with data-centric apps it is easy to control access and manage data, which are centered to the database. The Force.com platform is data-centric by its nature and it is a perfect platform to build and host data-centric apps.

  • Process-Centric Apps: A process-centric app is based on automating the business process in the organization and multiple users can be involved in the process. The Force.com platform has many features that align with the features of process-centric applications such as the approval process, the workflow, and security and sharing models.

  • Content-Centric Apps: These applications are intensely increasing the storage needs of on-demand performance. These kinds of applications have main functionalities such as version controlling, content management, and sharing.

  • Transaction-Centric Apps: The main functions of these types of applications are focused on transactions such as banking systems, stock market-related systems, and online payment systems.

Data and process-centric apps are the most suitable application types for the Force.com platform. The following two figures explain to us how the data-centric and process-centric apps are the most suitable apps for the Force.com platform:

Types of apps that are a good fit for the Force.com platform

Types of apps suitable for the Force.com platform

Design consideration

When we develop a system on the Force.com platform, we need to consider some facts about the design phase. As in traditional software development, identifying your stakeholders and business partners is the first thing you need to do. Then, you need to capture the business requirement from your stakeholders. By analyzing the captured requirement, you can identify the users of the applications and the security model of the application. The security model is the most important part of designing a Force.com application.

Tip

Do not keep the defining of the security model of the Force.com application to the end. It will only increase the rework required of the application's designing and development.

Customization on the Force.com platform

In the design phase, we can consider the development method, which can be used to develop the particular application. There are two development methods on the Force.com platform. They are as follows:

  1. Declarative Development: This development can be done using point and click with zero coding. We can do declarative development via the browser. The declarative customizations require an understanding of the Force.com platform overview, but no coding knowledge. The developments and deployments can be rapidly done using the declarative development method.

  2. Programmatic Development: Programmatic developments require coding skills and allow developments to extend beyond the declarative capabilities. For example, if we need to create a page with a wizard, we cannot fulfill that requirement with declarative development. We need to use programmatic development, such as Apex and Visualforce.

The following screenshot shows the Force.com development model. It illustrates the deviation development methods with the skills of the developer.

Force.com development model

Most complete and robust solutions actually use a combination of declarative and programmatic solutions. Developers should understand how to develop using both declarative and programmatic features. The following table shows the advantages of declarative and programmatic customizations:

Declarative customizations

Programmatic customizations

Ease of development (more visual and quicker to do)

Can extend the capabilities of an application beyond standard functionalities

Ease of upgrade

More control and flexibility over the application

Ease of maintenance

 
 

Identifying building blocks of the Force.com platform


Every application has some key components that are considered as the building blocks of the particular application. These building blocks define the application. An application of the Force.com platform also has three core components, which are as follows:

  1. Objects: The object is the main component of building the application on the Force.com platform. The Force.com platform doesn't allow accessing the database of a particular application. But we can create an object instead of a database table. Therefore, an object and object field will be respectively mapped to a database table and table columns of the particular table. There are two types of objects: standard objects and custom objects. Standard objects are used in CRM applications and they are created by Salesforce.com. The custom objects are created by developers according to their requirements. This book is focused on Force.com development. Therefore, you will work more with custom objects, and according to the requirements, you will work with standard objects. For further details, refer to Chapter 2, Building the Data Model.

  2. Tabs: These are the views of objects. We need to declare tabs if we want to insert data records in them. There are standard tabs that are created by Salesforce.com and custom tabs that can be created by developers. There are 3 types of custom tabs:

    1. Custom object tabs: On Force.com, when we create a custom object, a set of user interfaces are generated to add, edit, and view particular object records. These standard user interfaces can be bound to a custom object tab. While creating an object, it is asked at the bottom to launch the tab wizard, opening of which redirects us to the next page where we declare the tab of an object.

    2. Custom web tabs: These types of tabs are used to display external web applications or a web page in the Salesforce platform.

    3. Visualforce tabs: These types of tabs are used to bind and display a Visualforce page. More details about custom tabs will be described in Chapter 3, Building the User Interface.

  3. Application: An application is a group of tabs that work as a unit to provide functionality. A Saleforce.com organization can have multiple applications. The users can switch between apps in an organization. Then we need to have a method to define the logical boundary of the app. The number of custom applications in a particular organization depends on the Salesforce edition of the organization.

More details about the custom app will be described in Chapter 3, Building the User Interface.

 

The sample application


Let's introduce the leave management application called eLeaveForce. In this application, an employee can request a particular type of leave and his/her manager can approve the leave. We will maintain the leave types and leave categories as reference data (user defined data). A holiday calendar will be maintained for this leave management application. You can use this application to learn about different elements and features of the Force.com platform.

The following is the E-R diagram of the eLeaveForce application, which we will create on the Force.com platform:

E-R diagram of eLeaveForce

In this section, you will capture an idea about the leave management application and the design of the eLeaveForce application. Later, you will learn about the Force.com platform in depth by using this sample application.

There are six custom objects for our leave management application. These six custom objects are used to track the data of the leave management app. They are as follows:

  • Employee

  • Holiday Calendar

  • Leave (main leave object)

  • Leave Type

  • Leave Category

  • Leave Configuration

According to the requirement, these objects are connected with relationships as illustrated in the E-R diagram. More details about custom objects and relationships will be described in Chapter 2, Building the Data Model.

When we define the security model of the application, we need to consider the built-in security features of the Force.com platform. More details about sharing and security models will be described in Chapter 4, Designing Apps for Multiple Users and Protecting Data.

Our leave management app has a few approval processes, such as getting the approval for the particular leave. Approval processes are considered in our design and will be implemented using the in-built workflow and approval processes. More details about workflow and approval processes will be described in Chapter 5, Implementing Business Processes.

We will use Visualforce pages and Apex to accomplish the requirements that can be fulfilled beyond the declarative developments. For example, a graphical view of the current status of the leave process will be displayed on a Visualforce page. More details about Apex and Visualforce will be described in Chapter 7, Custom Coding with Apex and Chapter 8, Building Custom Pages with Visualforce.

 

Summary


In this chapter, we became familiar with the Force.com platform by examining its key features and advantages. You have learned the design considerations of an application on the Force.com platform and development methods of the Force.com platform. We discussed the building blocks of a Force.com application. We also captured the scenario and the E-R diagram of the sample application, which is going to continue in the next chapter.

About the Author

  • Chamil Madusanka

    Chamil Madusanka is a Salesforce.com-certified Force.com developer. He has been working on Force.com projects since 2011. He works as a developer on many custom applications built on Force.com and has also trained end users and new Salesforce developers at his current company (attune Lanka (Pvt) Ltd.) and former company (Sabre Technologies (Pvt) Ltd). He has authored Visualforce Developer's Guide, Packt Publishing.

    Chamil won the Salesforce New Year Resolution 2013 challenge, which was rolled out by Salesforce. He is an active member of the Force.com community and contributes through various channels. He is passionate about Force.com and shares his knowledge of Force.com technologies through his blog (http://salesforceworld.blogspot.com/). He is a super-contributor on the Force.com discussion board and shares his knowledge and experience on Force.com by providing effective answers to developer questions. He is the initiator and organizer of the Sri Lanka Salesforce Platform Developer User Group. His contribution to the Sri Lanka Salesforce community has led to an increase in Salesforce competency in Sri Lanka.

    He completed his BSc in computer science from the University of Colombo, School of Computing, Sri Lanka (UCSC). His areas of interest include cloud computing, semantic web technologies, and Ontology-based systems. Hailing from Polonnaruwa, an ancient city in Sri Lanka, he currently resides in Gampaha in the Western province of Sri Lanka. His interests include reading technology books and technology blog posts, and playing cricket. Chamil can be reached via twitter at @chamilmadusanka, Skype at chamilmadusanka, and e-mail at [email protected].

    Browse publications by this author