Full guide to Salesforce: from Chatter to Apex

In Managed IT

In this article we will talk about the Salesforce main product - CRM system and related solutions, from Salesforce Chatter to Apex language
Editorial Commitee Qualified.One,

We will look at what is hidden under the bonnet, assess the system from a technical point of view and try to understand who would be interested in working with it. 

Salesforce solutions

Salesforce has developed many solutions for different industries, and often these are standalone products, usually with the word Cloud in the name. Some specific solutions exist simply as pieces of functionality. Many of the Salesforce Clouds were previously standalone products and the companies that created them were absorbed and integrated with Salesforce. Some of them come as separate packages that can be installed on Salesforce org.

Below is an overview of the most popular Salesforce solutions.

Salesforce architecture

Salesforce architecture

Sales Cloud (Embedded, SaaS)

When talking about Salesforce, first and foremost, we think of the Sales Cloud - the core of the entire CRM. It has built-in objects (Lead, Contact, Account, Opportunity, Order, Quote, etc.) for working with customers and ready business logic (Lead Conversion, Lead Assignment, Forecasting, etc.). Allows you to build a pipeline, has rich reporting tools. Sales Console UI allows you to work with multiple records simultaneously.

Service Cloud (Embedded, partially available by default, SaaS)

The most profitable of all SF Clouds. Allows to handle customer complaints. Has a number of built-in objects (Case, Knowledge Article, etc.) and built-in business logic (Case Assignment, Case Escalating, Web-to-Case, Email-to-Case). A special kind of Salesforce UI has been developed for Service Cloud - Service Console. It allows you to conveniently work with multiple records without having to switch between tabs.

Experience Cloud

Experience Cloud (formerly Community Cloud) is a built-in, but not available by default, PaaS. Not much different from site builders, many companies, especially mid-sized ones, use its functionality to enhance interactions with customers, partners or employees. Tightly integrated with Salesforce itself, it's easy to set up automated content offloading from your CMS. Many built-in components replicate Salesforce functionality. Allows you to customize everything from your login page to your portal address.

Marketing Cloud

Marketing Cloud (partly built-in, but most of the functionality is in a separate SaaS package) is a B2C marketing solution, formerly a product of independent company Exact Target. Provides typical marketing tool functionality: bulk emails, email tracking, creating landing pages, running campaigns, etc.

Pardot (Separate website and package, SaaS)

B2B marketing solution, formerly a product of a third-party company. Enables form and landing page creation, visit tracking, lead scoring and marketing campaigns, and real time statistics.


CPQ (Configuration Price Quotes) - separate package, SaaS. Contains a rich toolkit for flexible pricing and sales configuration (including subscriptions), advanced management of the approval process. Can be supplemented with plug-ins to extend functionality.

Force.com sites

Force.com sites is a PaaS service designed to facilitate the development and deployment of cloud applications and websites.

Salesforce Chatter

Chatter is an enterprise messenger, a product of a third-party company taken over by Salesforce. It allows for the rapid creation of chatbots, but the company may consider it obsolete. The acquisition of Slack may have something to do with it.

Salesforce Chatter

Salesforce Chatter interface

Omni channel

Omni channel - a hub that connects different channels of communication with customers.

Einstein™ AI

Einstein™ AI - Artificial intelligence from Salesforce, mainly responsible for data analysis on your Salesforce org. Very limited in terms of programmatic interaction, it's almost entirely about customization and administration.

Integrations with Google products

Built-in integrations with Google products (Gmail, Calendar, Contacts, Drive), Microsoft (Outlook) and Amazon: in particular with AWS, where you can set up private connect bypassing HTTP/HTTPS traffic.

There are many other solutions for specific applications. The Government Cloud is designed for government organisations, the Healthcare Cloud connects patients and healthcare providers. The Vaccine Cloud, built on the Experience Cloud and integrated with the Government Cloud, makes it possible to quickly find a clinic for vaccinations and for the government and healthcare providers to simplify the process. For charities, there is the Non Profit Cloud, also known as the Nonprofit Success Pack or NPSP, which provides ten free licences. There is also, for example, the Education Cloud, the Industries Cloud, the Financial Service Cloud, the Commerce or B2C Commerce Cloud, which actively integrates with CMS, the Analytics Cloud, which integrates with Tableau, the Integration Cloud, which integrates with the Mulesoft internet bus.

SaaSy - the Salesforce salesforce.com mascot

SaaSy - the Salesforce salesforce.com mascot

What Salesforce is

Salesforce is headquartered in San Francisco, in the tallest skyscraper on the West Coast, the Salesforce Tower. It's quite a characteristic detail: the company loves attention; it's largely what its business relies on. Mark Benioff, a former sales executive who rose to vice president at Oracle, founded Salesforce in 1999 with a number of investors, including Geneva Venture Partners. Already in 2000, they made their presence felt by cheekily displaying a banner reading "The End of Software" in front of the conference venue for Siebel, a direct competitor and then market leader in CRM.

Salesforce from a developer's perspective

Salesforce provides users of its platform with ample scope for expansion and self-development. In fact, development on Salesforce is not much different from ordinary web development in terms of approach, technology and the tools themselves.

In Salesforce you can change the backend, the frontend and even the database model. There is declarative programming capability, and there are plenty of built-in tools. Of course, there are still nuances and limitations, and we'll talk about them next.

To start with, we need to remind you that Salesforce CRM is a fully cloud-based solution. This means that you don't have to compile anything on the local machine. Well, you can compile the classes yourself, but Salesforce handles this task automatically, so you rarely need to do it manually. In fact, this is only desirable when you change dependencies. Under the bonnet, Salesforce works with cached compiled classes.

A cloud-based system doesn't even need to be installed on a local server. Salesforce takes full responsibility for setting up and maintaining the servers, and its CRM architecture is multi-scale and distributed: the main servers are in the US, England, Germany, France and Japan, and those running on AWS infrastructure are in the US, Canada, India and Australia. One customer's databases are stored on the same server; moreover, there are reports that this data is stored in the same database as other customers' data. But for obvious reasons, the company is reluctant to share how the information is stored and generally tries to keep as many technical details secret as possible.

Salesforce has a Mobile SDK for creating custom Android and iOS apps for customer instances. In addition, there are official applications as well.

Salesforce database model

The system contains a number of built-in objects, a full list of which can be found here. You can also create your own - custom ones - for example, with the Unlimited Edition you can create 2000, and install another 1000 as part of packages. In Salesforce, the object that can be stored in the database is called a SObject, its counterpart in the relational database is a table. Mostly objects in Salesforce are created via a UI or Metadata API, but a SObject can also be created automatically from data imported from spreadsheets.

To store global variables, Salesforce uses Custom Settings or the newer Custom Metadata Types tool, which is widely used in package development. The advantage of Custom Settings is the ability to create unique hierarchical records for different user profiles, for example. In turn, for Custom Metadata Type you can create links between each other. In fact, there are other differences between these tools.

You can use the Translation Workbench tool to create language versions. When developing custom components, it is recommended to put all labels in Custom Labels, which support multilingualism. There is also support for different currencies with a date-specific exchange rate.

Salesforce database architecture

Salesforce database architecture

In Salesforce, the analogue of columns in a database table is fields. For custom fields, the following types are distinguished:

  • Auto Number - automatically numbers the record, allows you to create a template.
  • Checkbox - can accept true/false values.
  • Currency - type of currency used in ISO standard.
  • Date - Date is stored in GMT, but is displayed according to the time zone of the user who is viewing the field.
  • Date/Time - similar to the previous one, but also allows you to store the time.
  • Email - is designed to store email addresses.
  • External Lookup Relationship - special type of relationship that is used for integration with external systems.
  • Formula - values for the field-formula are not stored in the database, but are calculated directly at the moment of access to it. For the field allocated types: Checkbox, Currency, Date, Date/Time, Number, Percent, Text, Time.
  • Geolocation - allows to store coordinates: latitude and longitude.
  • Hierarchical Relationship - special type of relationship available for User object.
  • Indirect Lookup Direction - a special type of relationship between external objects.
  • Lookup Relationship - A weak relationship type.
  • Master-Detail Relationship - A strong relationship type where the child (detail) inherits the shared settings from the parent (master) owner. When the master deletes the record the detail is automatically deleted.
  • Number - this numeric type allows storing up to 18 digits (e.g. 18 digits of a whole number, or 16 digits of a whole number plus two digits of a fractional part).
  • Percent - to store percent, differently reflected in UI, formulas and Apex code.
  • Phone - fields for phone numbers, essentially text fields.
  • Picklist - Dropdown name in Salesforce. Although the database here is considered normalised, it includes this type of field, which contradicts the requirements for normalised databases.
  • Picklist (Multi-select) is another type that should not be in a normalized database. Stores values for multi select comboboxes, in the database the selected values are stored as a text field and separated by semicolons.
  • Roll-Up Summary - a special field type, available only on master objects, performs calculations using aggregation functions (COUNT, SUM, MAX, MIN). The values of deterministic functions are stored in the database, the rest are recalculated when the associated records are changed.
  • Text is a text field which allows storage of up to 255 characters.
  • Text (Encrypted) - text field which is encrypted using 128-bit AES key, limited to 175 characters.
  • Text Area - A text field limited to 131,072 characters, which stores tab characters.
  • Text Area (Rich) - allows you to save text up to 131,072 characters, formatted using HTML, supports a limited set of tags.
  • Time - the newest field type designed to store the time.
  • URL - is used to store hyperlinks.

Email, Number and Text fields can be used as External IDs, which is especially useful for migration or integration.

To implement a many-to-many relationship, Junction Objects are created which have two Master-Detail Relationship fields. Actually, two is the maximum for this type of field on a single object.

For fields, Salesforce has built-in support for privacy policies, including GDPR compliance. For text encoded fields, there's Classic Encryption (AES encryption in blocks of 128 bits). There's also a paid Salesforce Shield, which is not limited to text fields and uses AES encryption in blocks of 256 bits.

There's also built-in object, field, and record level access. Records can be shared automatically, e.g. with sharing rules and Apex managed sharing, or manually.

If you have billions of records, you can use a special tool, Salesforce Big Objects.


When talking about the backend, most often the focus is on Apex classes and triggers. Less often, some functionality on Heroku or integration with MuleSoft and DellBoomi platforms. Even more rarely is the term used to describe custom ETL solutions.

Salesforce recently announced the launch of Salesforce Functions, but the service is still in beta testing. The idea is that it's a FaaS (Functions-as-a-Service) tool that allows you to write backend solutions not only in Apex, but also in other programming languages, and integrate them seamlessly with your Salesforce instance.


Apex is a proprietary Java-like object-oriented programming language designed specifically to work with Salesforce CRM. The language is not case-sensitive, but it's still considered good practice to stick to cases when writing code in Apex.

Here's an example of Hello World written in Apex:

System.debug('Hello World!');

At the heart of Salesforce is transaction-based and event-based architecture, but it supports the ability to run code on demand or according to a previously fixed plan. All of this is reflected in the specifics of the programming language itself. For example, static variables will only be stored in the context of a single transaction (say, the creation of a record and all synchronous and some asynchronous actions called by it).

Salesforce Apex features

Features of the Salesforce Apex

The language contains the following data types:

  • Primitive: Blob, Boolean, Date, Datetime, Decimal, Double, Id, Integer, Long, Object, String, Time.
  • SObject - Standard and custom objects that are stored in the database.
  • Collections: List, Set, Map.
  • Typed list of values (enum).
  • Custom Apex classes.
  • System-defined Apex classes.
  • Null.

All data types are inherited from Object, all standard and custom objects are inherited from SObject.

Yes, Salesforce only has three types of collections. Arrays and Lists are actually the same here. But no one forbids you to create your own implementations of other collections, including the Iterator interface for this purpose. From experience, most often you have to implement a multi map.

As far as object-orientation is concerned, Salesforce is also specific: you can create classes, abstract classes and interfaces. For example, you can't define property signatures in an interface, but that's not the only limitation.

Here you can define class constructor, class initializer, but, for example, you cannot define destructors.

There is DML (Data Manipulation Language), SOQL (Salesforce Object Query Language) and SOSL (Salesforce Object Search Language) to work with the database. You don't need to set up a database connection or create DTO classes to manipulate records. This is probably the biggest advantage when working with a Salesforce database.

DML is a data manipulation language. It supports the following operations: insert, update, upsert, delete, undelete, and merge. DML works with a single record or a list of SObject records, either programmatically created by a user or retrieved via SOQL.

SOQL is an SQL-like query language. The main difference is the lack of Join support, but many other features are identical, albeit with their own limitations. For example, this is what a SOQL query would look like, which pulls data about accounts - objects responsible for companies - and their associated contacts:

code SELECT Id, Name, (SELECT Id, Name FROM Contacts) FROM Account

Here the contacts are linked to the company using the lookup field AccountId, and the name of the relationship in the particular case is Contacts.

SOQL can return:

  • One record (if there is a LIMIT of 1 or a specific Id is specified in WHERE).
  • An empty SObjects, Custom Setting or Custom Metadata Types list (when no record matches the criteria).
  • A list of SObjects, Custom Setting or Custom Metadata Types.
  • Aggregate results or just a number (e.g. for the COUNT aggregation function).

To optimize queries, it is possible to index fields, and some field types are indexed automatically.

SOSL is a query language designed only for searching. It is used much less frequently than SOQL, and is especially useful for writing global searches. An example SOSL query:

code FIND {"Joe Smith" OR "Joe Smythe"} IN Name Fields RETURNING lead(name, phone), contact(name, phone)

Based on well documented code, you can automatically generate documentation with ApexDoc. There are many services and plugins for static code analysis, the most popular being PMD.

Governor Limits

Since Apex runs in a multi-ball environment, Apex code execution is strictly limited to ensure that it does not monopolize shared resources. A limit is imposed on almost everything in the context of a single transaction: the number of SOQL lookups; the number of SOSL queries they return; the number of DML operations; Heap size; CPU Time, etc. For asynchronous Apex these restrictions are not so strict.

Asynchronous Apex

The following types of asynchronous Apex are available:

  • Future - used for relatively short callouts (up to 60 seconds).
  • Continuation - used for long callouts[13][14] , available for VisualForce, and more recently for Aura and LWC.
  • Batch - allows asynchronous processing of large amounts of data, helps bypass Governor Limits.
  • Queueable - like Batch, it is used to process large amounts of data. The main advantage over Batch is the ability to call another Queueable, i.e. to form a chain.
  • Schedualble - allows you to run code at a particular time and interval.

Event-based architecture

Platform Events (publish-subscribe model for communication with external applications, also used to implement resource-intensive functionality), Change Data Capture Events (used to process record changes), conventional and asynchronous triggers are used to create Event-based architecture.

Security and access control in Salesforce

In the user profile, you can grant or deny access to an Apex class.

Like many C-like programming languages, Apex has the following access modifiers: private, protected, public. In addition to these, Apex has another one, global, which is most often used when developing third-party packages, less often to implement some standard interfaces.

When you declare a class, you can also specify keywords: with sharing (all sharing rules, CRUD, FLS will be followed), without sharing (code will have access to all records and full access to CRUD and FLS), inherited (means that class sharing mode will depend on the sharing mode of the class which called it).

Example class declaration:

public inherited class AccountService {}

Salesforce Web and Email services

With Apex you can develop complete SOAP-, REST-based Web and Email services. For example, Apex REST supports the following data types for parameters and return values.

  • Apex primitives (excluding Object and Blob).
  • sObjects.
  • Lists or map primitives of Apex or sObjects (only map with string keys are supported).
  • User-defined types that contain variables which are members of the above types.

You can use Email Services to handle the content, headers and attachments of incoming email. For example, you can create an Email Service that automatically creates contact records based on contact information in messages.

Unit tests

The code in the Production-org cannot be edited directly, so the "once, now into production" principle does not work here. The code is written and tested, for example, in Sandbox, and it is only deployed to Production. And the code must be at least 75% covered by unit tests and not crash during deployment, at least locally. There are no such requirements for Sandbox => Sandbox deployment.


For debugging Apex code, there are Debug Logs with different logging levels. Traced Flags can be created for: 1) an automated process; 2) Platform Integration; 3) a specific user; 4) an Apex class; 5) an Apex trigger. Breakpoints can be placed in the code for better debugging.

Apex triggers

It is possible to create before- and after-triggers for the following DML-operations: insert, update, delete, undelete (restore a record which was previously removed to the recycle bin). Only an after-trigger can be defined for an undelete operation. Depending on the operation, the following context variables are available: Trigger.new (List with modified values), Trigger.old (List with values before modification), Trigger.newMap (Map is the same as Trigger.new, only as Map), Trigger.oldMap (Map is the same as Trigger.old, only as Map) and others. Upsert DML operation is a mix of Insert and Update, merge is a mix of Update and Delete.

As a rule, all code from triggers are moved to separate handler-classes, and code which can be reused is moved to service-classes. Although there are a lot of approaches and trigger frameworks.

To offload triggers, asynchronous triggers that are executed after a transaction is completed are used. To offload an Apex trigger to Production, you need to cover at least one line of its code with a unit test.

Every Salesforce developer should be mindful of the Order of execution. Since a DML transaction runs not only the trigger, but also a lot of other declarative functionality, in some cases this can cause recursion and result in exceeding Governor Limits.


The company, founded just before the dot-com crash, has not only passed the test with flying colours, but, by demonstrating an innovative approach to CRM, has cemented itself as a leader. Salesforce has long ceased to be just a customer relationship management system: the system has become enriched with solutions for many industries, developed in-house or by third parties. Direct competitors can only dream of squeezing Salesforce, and respected analysts predict the company will continue to grow.

Even the relatively high price of Salesforce products is not deterring customers, mostly medium- and large-sized businesses. At the same time, there are solutions for very small companies as well. However, there are also many limitations, and I am certainly not going to convince you that Salesforce will necessarily be of interest to you. In part two of this article, we will talk about who is likely to want to look at CRM and other Salesforce infrastructure. It will also talk about Salesforce frontend and deployment, embedded declarative programming tools, process and development environments. Finally I promise to share a reference list for developers and administrators, useful links and extensions for Chrome.