Shopping cart

Subtotal:

$0.00

PDI Developer Fundamentals

Developer Fundamentals

Detailed list of PDI knowledge points

Developer Fundamentals Detailed Explanation

1.1 Data Modeling and Management

Core Concepts

1. Object Model

What is an Object?

  • An object in Salesforce is like a database table that stores specific information.
  • Each object contains fields (columns in a database) and records (rows in a database).
Types of Objects
  1. Standard Objects:

    • Predefined by Salesforce to represent common data structures.
    • Examples:
      • Account: Represents companies or individuals you're working with.
      • Contact: Stores details of people related to accounts.
      • Opportunity: Tracks sales deals in progress.
      • Case: Manages customer support issues.
    • You cannot delete standard objects, but you can customize them.
  2. Custom Objects:

    • Created by users for specific business needs.
    • Examples:
      • Student: For schools, a custom object might track student details.
      • Order: For businesses, it might track customer purchases.
    • Features:
      • Custom fields, relationships, and layouts can be added.
      • Custom objects have a "__c" suffix in their API name (e.g., Student__c).
Schema Builder
  • What is Schema Builder?
    • A drag-and-drop tool in Salesforce that visually represents objects and their relationships.
    • Found in: Setup > Object Manager > Schema Builder.
  • Why Use Schema Builder?
    • Helps you visualize the structure of objects and fields.
    • Makes it easy to create or modify objects and relationships.
2. Field Types

Fields are the building blocks of an object, representing the data stored in it. Salesforce provides different field types for flexibility:

  1. Scalar Fields:

    • Basic fields to store single values.
    • Examples:
      • Text: Stores alphanumeric data.
      • Number: Stores numeric values (e.g., 42, 3.14).
      • Date: Stores calendar dates (e.g., 2024-01-01).
  2. Formula Fields:

    • Automatically calculate values based on other fields or formulas.

    • Example:

      • Formula: Calculate an employee's age from their date of birth:

        TODAY() - Birthdate
        
  3. Relationship Fields:

    • Link one object to another for creating relationships.
    • Types of Relationships:
      • Lookup:
        • Creates a loose connection between objects.
        • The field can be null.
        • Example: A Contact can look up to an Account.
      • Master-Detail:
        • Creates a strong connection between objects.
        • If the parent is deleted, the child is also deleted.
        • Example: Invoice Line Items (child) are tied to an Invoice (parent).
      • Many-to-Many:
        • Allows linking of multiple records from two objects.
        • Achieved using a Junction Object.
        • Example: A custom object Project__c can have multiple employees and vice versa.
3. Design Tips
  1. Choose Field Types Wisely:

    • Use Number instead of Text for numeric data to support calculations.
    • Use Picklists for predefined options to maintain consistency.
  2. Avoid Deeply Nested Relationships:

    • Too many Master-Detail relationships create dependency complexity.
    • Limit nesting levels to improve performance and maintainability.

1.2 Apex Programming Language

Core Concepts

What is Apex?

  • Apex is Salesforce's proprietary programming language.
  • It's strongly-typed and object-oriented, meaning it enforces strict rules about data types and syntax.
  • Similar to Java, but designed to work within Salesforce's platform limits.
Apex Syntax Basics
  1. Variable Declaration:

    • Stores values for processing.

    • Example:

      String name = 'John';
      Integer age = 30;
      Boolean isActive = true;
      
  2. Control Structures:

    • Used for decision-making and iteration.

    • Examples:

      • if-else:

        if (age > 18) {
           System.debug('Adult');
        } else {
           System.debug('Minor');
        }
        
      • for loop:

        for (Integer i = 0; i < 5; i++) {
           System.debug('Count: ' + i);
        }
        
  3. Data Structures:

    • List: An ordered collection of items.

      List<String> names = new List<String>{'John', 'Jane'};
      
    • Set: A collection of unique items.

      Set<Integer> uniqueNumbers = new Set<Integer>{1, 2, 3};
      
    • Map: Key-value pairs.

      Map<Integer, String> students = new Map<Integer, String>();
      students.put(1, 'John');
      
Methods and Classes
  1. Static Methods:

    • Can be called without creating an instance of a class.

    • Example:

      public class Utility {
         public static void sayHello() {
             System.debug('Hello, Salesforce!');
         }
      }
      
  2. Encapsulation:

    • Use access modifiers to control the visibility of classes, methods, or variables:
      • private: Only accessible within the class.
      • public: Accessible anywhere.
      • global: Accessible across all namespaces.
Triggers

What is a Trigger?

  • A Trigger automates actions in Salesforce when specific events occur, such as inserting or updating a record.

  • Example:

    trigger AccountTrigger on Account (before insert, after update) {
        for (Account acc : Trigger.new) {
            acc.Description = 'Auto-updated description';
        }
    }
    
  • Best Practices:

    • Avoid recursion by using static variables.
    • Use one trigger per object for simplicity.

1.3 SOQL and SOSL

SOQL (Salesforce Object Query Language)

  • Retrieves data from Salesforce.

  • Example:

    SELECT Id, Name FROM Account WHERE Industry = 'Technology'
    

SOSL (Salesforce Object Search Language)

  • Performs full-text searches across multiple objects.

  • Example:

    FIND 'Smith' IN Name Fields RETURNING Contact(Id, Name)
    

1.4 Platform Limits (Governor Limits)

Why Governor Limits?

  • Salesforce uses multi-tenant architecture, meaning multiple organizations share the same resources. Limits ensure fair usage.

Examples of Limits:

  • SOQL Queries: Max 100 per transaction.
  • DML Operations: Max 150 per transaction.
  • CPU Time: Max 10 seconds for synchronous operations.

1.5 Development Tools

  1. Developer Console:

    • Debug and test code directly in Salesforce.
  2. Salesforce CLI:

    • Command-line tool for metadata management.
  3. Visual Studio Code (VS Code):

    • Modern IDE with Salesforce extensions for coding Apex and LWC.

Developer Fundamentals (Additional Content)

1. Salesforce MVC Architecture

Salesforce follows the Model-View-Controller (MVC) architecture, which is a design pattern used to separate application logic, data, and user interfaces. This ensures better organization, scalability, and maintainability of the system.

1.1 Model (Data Layer)

The Model represents the data and business logic of the application. In Salesforce, the data layer is composed of the following:

  • Standard Objects: Predefined objects provided by Salesforce, such as Account, Contact, Opportunity, and Case.
  • Custom Objects: User-defined objects created to store organization-specific data.
  • Fields: Attributes of objects that store specific pieces of data, such as Name, Email, Amount, etc.
  • Relationships: Define how different objects are related to each other. The main types are:
    • Lookup Relationships: Loose connection between objects.
    • Master-Detail Relationships: Strong relationship where the child record depends on the parent.
    • Junction Objects: Used to create many-to-many relationships.

1.2 View (User Interface Layer)

The View is responsible for displaying data to users and capturing user interactions. In Salesforce, this includes:

  • Lightning Pages: Customizable UI layouts that display records and components.
  • Visualforce Pages: Custom pages built using <apex> tags, often used for complex UI needs in Salesforce Classic.
  • Lightning Web Components (LWC): Modern UI components built using HTML, JavaScript, and CSS that provide dynamic and high-performance interfaces.

1.3 Controller (Logic Layer)

The Controller layer handles business logic and user interactions. In Salesforce, this consists of:

  • Apex Classes: Custom business logic implemented using the Apex programming language.
  • Triggers: Code that runs automatically when records are inserted, updated, or deleted.
  • Workflows & Process Builder: Declarative automation tools used for updating records and sending notifications.
  • Flows: A more powerful automation tool that allows multi-step processes, loops, and decisions.

2. Apex Security

Security is a critical part of Salesforce development, ensuring that data is accessed only by authorized users. Apex security mechanisms include Field-Level Security (FLS), CRUD (Create, Read, Update, Delete) Permissions, and Sharing Rules.

2.1 Field-Level Security (FLS)

  • FLS controls which fields users can view or edit.
  • Example: A sales representative may see a customer’s email but not their salary.
  • Implemented via Profiles, Permission Sets, and Apex code checks.

2.2 CRUD Permissions

  • Defines whether a user can Create, Read, Update, or Delete records in an object.

  • Best practice: Enforce CRUD checks in Apex to prevent unauthorized data access.

  • Example: Checking Read Access

    if (Schema.sObjectType.Account.fields.Industry.isAccessible()) {
        Account acc = [SELECT Industry FROM Account WHERE Id = :someId];
        System.debug(acc.Industry);
    } else {
        System.debug('User does not have access to Industry field.');
    }
    

2.3 Sharing Rules and Apex Security Mode

Salesforce uses a record-level security model where users can access data based on ownership and sharing rules.

  • With Sharing: Enforces organization-wide sharing settings.
  • Without Sharing: Allows unrestricted data access (not recommended unless necessary).

Example: Enforcing Sharing Rules in Apex

public with sharing class SecureAccount {
    public static List<Account> getAccounts() {
        return [SELECT Id, Name FROM Account]; // Enforces record-level security
    }
}
  • Without Sharing Example (Avoid unless necessary):

    public without sharing class AdminUtility {
        public static List<User> getAllUsers() {
            return [SELECT Id, Name FROM User]; // Ignores sharing rules
        }
    }
    

3. Asynchronous Apex

Asynchronous Apex allows operations to run in the background, preventing long-running processes from blocking user actions.

3.1 Future Methods

  • Best for short background tasks (e.g., external API calls).

  • Cannot return values.

  • Example:

    public class AsyncExample {
        @future
        public static void processRecords(Set<Id> recordIds) {
            List<Account> accs = [SELECT Id, Name FROM Account WHERE Id IN :recordIds];
            // Process data asynchronously
        }
    }
    

3.2 Queueable Apex

  • Enhances Future Methods by allowing complex objects and method chaining.

  • Example:

    public class QueueableExample implements Queueable {
        public void execute(QueueableContext context) {
            System.debug('Running Queueable Apex...');
        }
    }
    

    To execute:

    System.enqueueJob(new QueueableExample());
    

3.3 Batch Apex

  • Best for processing large datasets (up to millions of records).

  • Example:

    global class BatchExample implements Database.Batchable<sObject> {
        global Database.QueryLocator start(Database.BatchableContext bc) {
            return Database.getQueryLocator('SELECT Id FROM Account');
        }
        global void execute(Database.BatchableContext bc, List<Account> scope) {
            for (Account acc : scope) {
                acc.Name += ' - Updated';
            }
            update scope;
        }
        global void finish(Database.BatchableContext bc) {
            System.debug('Batch Job Finished');
        }
    }
    

    To execute:

    Database.executeBatch(new BatchExample());
    

4. Metadata API & Deployment

Salesforce provides multiple ways to deploy metadata between environments.

4.1 Metadata API

  • Used to import/export Salesforce metadata (e.g., objects, triggers, Apex code).
  • Works through SOAP-based API calls.

4.2 Deployment Tools

Tool Use Case
Change Sets UI-based tool for small deployments
Salesforce CLI (SFDX) For DevOps automation and CI/CD
GitHub Integration Version control for source-driven development

4.3 Using SFDX for Deployment

Salesforce DX (SFDX) is a powerful CLI tool for automating metadata deployment.

Example: Deploying metadata with SFDX

  1. Authenticate to Salesforce:
sfdx force:auth:web:login -r https://login.salesforce.com
  1. Deploy metadata:
sfdx force:source:push -u MyDevOrg
  1. Retrieve latest metadata:
sfdx force:source:pull -u MyDevOrg

4.4 CI/CD in Salesforce

  • Continuous Integration/Continuous Deployment (CI/CD) automates deployments using tools like GitHub Actions, Jenkins, and Bitbucket Pipelines.

  • Example GitHub Actions Workflow:

    name: Deploy to Salesforce
    on: push
    jobs:
      deploy:
        runs-on: ubuntu-latest
        steps:
        - name: Checkout code
          uses: actions/checkout@v2
        - name: Deploy to Salesforce
          run: sfdx force:source:deploy -p force-app -u MyDevOrg
    

CI/CD Benefits:

  • Automates testing and deployment.
  • Ensures consistent, error-free releases.
  • Enhances team collaboration with version control.

Frequently Asked Questions

Why does a trigger that loops through Trigger.new work, but querying the same records with SOQL inside the trigger may fail or behave differently?

Answer:

Triggers should normally use Trigger.new instead of querying the same records again with SOQL.

Explanation:

Trigger.new contains the records currently being processed by the trigger. These records may not yet be committed to the database when the trigger runs, especially in before triggers. If a developer queries the database for those same records, Salesforce may return outdated or incomplete data because the transaction has not finished writing changes yet.

Using Trigger.new guarantees access to the correct in-memory version of the records. It also avoids unnecessary SOQL queries, which helps prevent hitting governor limits. Developers often mistakenly write queries inside triggers when the required data is already available in the trigger context variables. Best practice is to use Trigger.new, Trigger.old, and related collections for processing records.

Demand Score: 78

Exam Relevance Score: 88

When should a developer use a Validation Rule instead of Apex or Flow?

Answer:

Use a Validation Rule when enforcing simple data validation logic on a record.

Explanation:

Validation Rules are declarative tools designed to enforce data integrity conditions without writing code. If the requirement is simply checking field values (for example, preventing an Opportunity from closing without a required field), a Validation Rule is usually the most efficient solution.

Using Apex or Flow for basic validation introduces unnecessary complexity and maintenance overhead. Validation Rules execute quickly and are easy for administrators to maintain. Apex triggers should be reserved for complex logic such as multi-object updates, integrations, or calculations that declarative tools cannot handle. Flows are best for orchestrating multi-step automation processes.

Choosing the simplest solution first is a key Salesforce development principle often tested on the PDI exam.

Demand Score: 70

Exam Relevance Score: 85

Why should developers avoid performing DML operations inside loops in Apex?

Answer:

Because performing DML inside loops can exceed Salesforce governor limits.

Explanation:

Salesforce enforces strict governor limits to ensure fair resource usage across its multi-tenant platform. One of these limits allows only 150 DML operations per transaction. If a developer places insert, update, or delete statements inside a loop, the code may execute a DML operation for each record processed.

For example, processing 200 records could trigger 200 DML operations, exceeding the limit and causing a runtime exception. The recommended pattern is bulkification: collect records into a list during the loop and perform a single DML operation afterward.

Bulkification ensures the code works efficiently for both single records and large batches processed by triggers, API calls, or data loads. This concept is fundamental in Salesforce development and appears frequently in certification questions.

Demand Score: 75

Exam Relevance Score: 92

Why is understanding Salesforce Order of Execution important for developers?

Answer:

Because it determines how automation tools interact and execute when a record is saved.

Explanation:

Salesforce executes multiple automation tools in a defined sequence whenever a record is created or updated. This sequence includes validation rules, triggers, workflows, flows, and assignment rules.

If developers do not understand this order, they may experience unexpected behavior such as triggers firing twice, validation rules blocking updates, or workflows modifying fields after triggers run. For example, a workflow field update can cause triggers to execute again within the same transaction.

Understanding the execution order helps developers design reliable automation and avoid recursion or unintended updates. It also helps when debugging complex automation involving multiple tools like Flow and Apex triggers.

Demand Score: 66

Exam Relevance Score: 83

PDI Training Course