🧑‍💻

Salesforce Development with Salesforce Apex

Jul 3, 2024

Salesforce Development with Salesforce Apex

Introduction

  • Speaker: Amit Singh
    • 9+ years of experience in Salesforce
    • Educator at various platforms
    • Awarded Salesforce MVP 3 times
    • 21 Salesforce certifications
    • Leading Salesforce Architect Group in India
  • Series: Salesforce development with Salesforce Apex Hours
  • Agenda:
    • Introduction to Salesforce
    • Introduction to Apex
    • Basics including data types, operators, access modifiers, and control structures
    • Tools for developers

Salesforce Overview

  • What is Salesforce?
    • CRM platform
    • Used to manage sales, customer relationships, partnerships, and growth
    • SaaS platform (software as a service)
  • Salesforce Products:
    • Sales Cloud: Sales management
    • Service Cloud: Case management and customer service
    • Experience Cloud: Website development
    • Marketing Cloud: Marketing automation
    • Integration Tools: MuleSoft Composer
  • Developer Tools:
    • Free Developer Org: Sign up at developer.salesforce.com/signup
    • Sandbox environment for testing and development
  • Multi-Tenant Platform:
    • Single server shared by multiple customers
    • Utilizes governor limits to ensure fair resource usage

Setting Up Developer Org

  • Sign-up Process:
    • Visit developer.salesforce.com/signup
    • Fill out the required fields
    • UNIQUE username (doesn't need to match email)
    • Verify your email and log in
  • Developer Console:
    • Access via Gear icon -> Developer Console
    • Execute anonymous window for coding

Introduction to Apex

  • What is Apex?
    • Strongly typed, object-oriented programming language
    • Purely OOP
    • Developed, managed, and maintained by Salesforce
    • Syntax similar to Java
  • Data Types:
    • Primitive Types: String, Integer, Decimal, Double, Boolean
    • Standard Objects: Account, Contact
    • Collection Types: List, Set, Map
    • Default value for variables: null

Creating Variables in Apex

  • Syntax: String name = 'Amit Singh'; Integer age = 30; Boolean isAdmin = false;
  • System Debug:
    • System.debug(variable); to output variable values
  • Example: String name = 'Amit Singh'; System.debug(name); // outputs 'Amit Singh'

Operators in Apex

  • Arithmetic Operators: +, -, /, *
  • Assignment Operators: =, +=, -=, *=, /=
  • Logical Operators: && (AND), || (OR)
  • Equality Operators: == (equals), != (not equals)
  • Increment/Decrement: ++, --
  • Null Coalescing Operator: ??
  • Usage: Integer a = 10; Integer b = 20; Integer sum = a + b; System.debug(sum); // outputs 30 sum += 10; // equivalent to sum = sum + 10;

Control Statements

  • If-Else Statement: if (condition) { // logic if true } else { // logic if false }
    • Nested If-Else possible
  • Example: Integer age = 40; if (age >= 60) { System.debug('Old Age'); } else if (age >= 50) { System.debug('Medium Age'); } else { System.debug('Youth'); }

Tools and Resources

  • Developer Console: Tool for writing and executing Apex code
  • VS Code: Modern IDE for Salesforce development
  • Accessing Developer Console:
    • Gear icon -> Developer Console
    • Writing code using Execute Anonymous Window