Understand multi-tenant concepts and design frameworks, such as MVC architecture and Lightning Component Framework.

After studying this topic, you should be able to:

  • Describe the features and how system resources are accessed and applications developed in a multi-tenant environment.
  • Identify the considerations related to system updates in a multi-environment and use of shared resources.
  • Identify the different components of the MVC architecture and what they represent.
  • Describe the main features of the Lightning Component Framework.
  • Describe the features available for building applications using declarative and programmatic tools.

Table of Contents

  • MVC Architecture
  • Lightning Component Framework
  • App manager
  • Lightning App Builder
  • Declarative Tools
  • Programmatic Tools
  • Lightning Platform APIs

Introduction - Multi-Tenant Architecture

  • Salesforce has a multi-tenant architecture with unique features:
    • Cloud computing: Platform as a Service (PaaS)
    • Shared system resources: CPU usage, queries, and records returned are limited per customer
      • If governor limits are exceeded, exceptions are thrown - these can be designed for
    • Automatic system updates: upgrades roll out 3x per year in Spring, Summer, and Winter
    • Metadata-driven kernel: architecture separates runtime database engine (kernel), tenant data, and metadata

MVC Architecture

  • MVC is an architectural pattern that separates data layer from business logic/how data is presented in the user interface
    • Model: represents structure of the data through sObjects, fields, Apex classes
      • Standard objects, custom objects, object fields, object relationships, apex classes (data)
    • View: represents the presentation layer which consists of pages and components
      • Standard pages, visualforce pages, visualforce components, custom tabs, page layouts
    • Controller: represents the business logic. Custom controllers/controller extensions are Apex classes
      • Standard controllers, custom controllers (apex), extensions (apex), declarative rules and tools (apex triggers, validation rules, processes, etc)

Lightning Component Framework

  • Lightning Component Framework is a UI framework for building single-page web apps
    • Uses stateful JavaScript on Client side, stateless Apex on Server side - client only calls the server when necessary, so apps are more responsive and efficient
    • Lightning components can be built using Aura Components or Lightning Web Components model, which can coexist
    • Event-Driven Architecture: components are capable of listening to events and responding
  • Aura/LWC web components follow MVCC (Model-View-Controller-Controller):
    • Model: database (sObjects, fields, Apex classes)
    • View: lightning component
    • Controller (client-side): Javascript - client-side operations, intermediary between server and UI
    • Controller (server-side): Apex - performs database operations, JavaScript calls Apex methods
  • Lightning Component framework - set of prebuilt self-contained and reusable components
    • Aura components:
      • Only requires a markup file, but can also include controller, helper, CSS styles, design, documentation, renderer, and/or SVG files
    • Lightning Web component:
      • Follows web standards, typically contain HTML, JavaScript, CSS, and/or XML files

App manager

  • Apps: groups of tabs that work together as a unit, created from the App Manager in setup
    • Item at the top of list in Navigation Bar become the app’s landing page
    • Lightning apps contain standard and custom tabs, Visualforce tabs, Lightning component tabs, Canvas apps, web tabs, Lightning Page tabs, and utilities like Sales Dialer.
    • Utility Items can be added to the utility bar
    • Navigation style (standard or console) and navigation rules for the Console navigation style (open as Workspace tabs/subtabs)
    • Form factors (mobile, desktop, both)
    • Only profiles assigned to the app will be able to access it

Lightning App Builder

  • Lightning App Builder is a declarative tool that can be used to create and configure custom pages for Lightning Experience and Salesforce mobile app
    • Lightning App Builder allows building single-page apps, dashboard-style apps, “point” apps that solve a particular task, custom record pages, custom Home pages, custom email application panes
    • Standard lightning components include Accordion, Chatter, Record Detail, Related Record
    • Custom lightning components can be added to a lightning page
    • Dynamic lightning pages make it possible to configure when a component appears on a Lightning page by adding filter conditions and logic in Lightning App Builder

Declarative Tools

  • Declarative automation tools can be used to implement simple and complex business processes:
    • Process Builder: useful when complexity of a business process consists of multiple if/then statements
      • Can be used to: create new records, update any related record, invoke Apex code, create a Chatter post, send an email alert, submit a record for approval, launch a flow or other process, send a custom notification
    • Flow Builder: automate a guided visual experience, start a business process from a user interaction, process, schedule, platform event, or record change.
      • Can be used to: create new records, delete records, launch another flow, update any record, send an email alert, send a custom notification, invoke Apex code, submit a record for approval, create a Chatter post, send an outbound message
    • Approval Process: can be used to submit a record for approval when a user clicks a button/link or when a flow/process submits a record for approval
      • Can be used to: create new tasks, send an email alert, update the original record or its parent, send an outbound message
    • Workflow Rule: can be used to implement a business process that consists of a single if/then statement
      • Can be used to: create new tasks, send an email alert, update the original record or its parent, send an outbound message
  • Declarative sharing & security tools can be used to expose different data sets to different sets of users
    • Profiles & Permission Sets: can be used to specify objects and fields that users can access as well as user permissions
    • Record Access controlled by specifying org-wide default sharing settings
  • Declarative business logic & validation tools
    • Roll-up summary fields: can be used to automatically calculate the value of a field on a parent record based on child records
    • Validation rules: can be used to verify that the data entered by a user meets certain standards before the record is saved
  • Declarative user interface tools
    • App Manager: container for a set of items like object tabs/utility items
    • Lightning App Builder
    • Quick Actions: Object-specific and global quick actions let users invoke custom functionality when using the UI
  • Declarative data management tools
    • Data Import Wizard: supports imports of up to 50,000 records
    • Dataloader: supports insert, update, upsert, delete, or export of up to 5,000,000 records.
  • Declarative analytics tools
    • Report Builder, Dashboards, Report and Dashboard Folders

Programmatic Tools

  • Programmatic features are used when a required functionality cannot be achieved using declarative tools
  • Apex: used for complex business logic for apps.
    • Invocable Apex method: can be created and invoked as an Apex action in a process or flow
    • Apex triggers: can be created to execute custom business logic before/after a record is created/updated/deleted/merged/upserted/undeleted
    • Used for integration with external systems
  • Visualforce: framework that can be used to build custom user interfaces, mainly for Salesforce Classic
    • Uses a tag-based markup language consisting of Visualforce tags, HTML, JavaScript, or other Web-enabled code embedded within a apex:page tag.
    • Can be used to override standard buttons, define custom tabs, create dashboard components, etc
  • Apex class below contains invocable method callable from Flow Builder or Process Builder
// An Apex class is allowed to have one (1) invocable method only
public class CustomBusinessLogic {
    @InvocableMethod
    public static void processAccounts() {
        // perform logic or process which a declarative tool is not capable of achieving
        ...
    }
}
  • Call the function above in Process Builder by specifying an “Action Type” of “Apex”
  • Lightning Aura Components: the original aura components model includes aura components that are self-contained, reusable units of an app that represent sections of the UI
  • Lightning Web Components: uses core Web Components standards. HTML and modern JavaScript can be used to build LWCs.
  • Aura and Lightning web components can be used in custom tabs, Lightning pages, Experience Builder, Flows, Visualforce pages, etc

Lightning Platform APIs

  • Wide range of useful APIs for various scenarios:
    • REST API: programmatically access or process Salesforce data from an external application
    • SOAP API: access, search, and perform DML operations on records from an external application
    • Chatter REST API: show Chatter related data such as feed, users, or groups
    • User Interface API: build user interfaces that surface records, list views, quick actions, favorites, and other components
    • Analytics REST API: grants programmatic access to Salesforce Analytics data such as datasets, lenses, and dashboards
    • Bulk API: lets developers and admins perform CRUD actions on large datasets (hundreds of thousands to millions of records) asynchronously in batches
    • Metadata API: allows developers to programmatically retrieve, deploy, create, update, or delete customizations or metadata in an org
    • Streaming API: used in receiving notifications based on record-change events or custom events in Salesforce
    • Apex REST API: allows Apex classes to be exposed and invoked by external applications as REST web services
    • Apex SOAP API: allows Apex classes to be exposed and invoked by external applications as SOAP web services
    • Tooling API: provides ability to write SOQL queries for many metadata types in an org