SlideShare a Scribd company logo
Path to Code
Begin Your Salesforce Coding Adventure
Episode 2
Conditional Statements, Ternary Operators, Loops
Enterprise Solutions Architect
Global Salesforce Community Speaker
4x Salesforce Certifications
Jigar Shah
Agenda
• Need for Control Flow Statements
• Control Flow Statements
• Iteration using Loops
• When to use List vs Set vs Hash map?
• Trailhead Modules
• Q&A
Some Housekeeping Rules…
• Mute your mic
• Keep adding questions in Zoom Q&A Window
• No questions are silly!
• Questions will be answered in the last 15 mins of this session
Need for Control Flow Statements
Conditional
Execution
Comparison
of Data
Computation
of Data
Traversal
over Data
Elements in
Collections
Repeated
Execution
Control Flow Statements
Control Flow Statements govern the behavior of your Apex
code
Types of Control Flow Statements
• Conditional
• Iterative
Conditional Statements
Conditional Statements in Apex
1. If Else…
2. Switch Statements
3. Ternary Operators
If Else Statements
if(Boolean Condition){
//Code Block
}
else{
//Code Block
}
if(Boolean Condition1){
//Code Block
}
else if(Boolean Condition2){
//Code Block
}
else if(Boolean Condition3){
//Code Block
}
else{
//Code Block (Optional Default Condition)
}
Operators
Fuel your decisions!
Operators
Ternary Operators
• Uses ? : (Boolean Condition) ? Value if True : Value if False
• Left Associative
• Short-hand for if-then-else statements.
Switch Statements
switch on expression{
when value1, value2{
//Code Block
}
when value3{
//Code Block
}
when value4{
//Code Block
}
}
• Match 1 of the several available values
• Switch expression can have – String, Sobject,
Enum, Integer, Long, Methods
• Apex types are Nullable
Iterative Statements - Loops
Iterative Statements
5 Types of Procedural Loops in Apex
 Do {Code Block} While (Boolean Exit Condition)
 While (Boolean Exit Condition)
 For
 For (Initialization; Boolean Exit Condition; Increment) {Code
Block}
 For (Variable : Array or Set) {Code Block}
 For (Variable : [Inline SOQL Query]) {Code Block}
Choosing List Vs Set Vs Map
• List
• Map
• Set
Resources
 Control Flow Statements
 Expressions & Operators
 Switch Statements
 Loops
Trailhead Modules
Platform Development Basics Apex Basics & Database Developer Console Basics
Q & A
Thank You
Subscribe

More Related Content

PPTX
Episode 4 - Introduction to SOQL in Salesforce
PPT
Salesforce Integration
PPTX
SOQL in salesforce || Salesforce Object Query Language || Salesforce
PPTX
Salesforce Basic Development
PDF
Best Practices with Apex in 2022.pdf
PPTX
Introduction to apex code
PPTX
Episode 10 - External Services in Salesforce
PPTX
Introduction to Apex for Developers
Episode 4 - Introduction to SOQL in Salesforce
Salesforce Integration
SOQL in salesforce || Salesforce Object Query Language || Salesforce
Salesforce Basic Development
Best Practices with Apex in 2022.pdf
Introduction to apex code
Episode 10 - External Services in Salesforce
Introduction to Apex for Developers

What's hot (20)

PDF
Apex Design Patterns
PDF
Apex Design Patterns
PDF
Creating a Data validation and Testing Strategy
PDF
Apex Enterprise Patterns: Building Strong Foundations
PDF
Query Optimization - Brandon Latronica
PDF
SLDS and Lightning Components
PPTX
Aggregate function
PPTX
Episode 20 - Trigger Frameworks in Salesforce
PPT
Salesforce Tutorial for Beginners: Basic Salesforce Introduction
PPT
Amazon Simpledb
PPTX
Query optimization
PDF
Integrity constraints in dbms
PPT
SQL Queries
PPTX
SQL(DDL & DML)
PPT
SQL Injection
PDF
CNIT 129S: Ch 7: Attacking Session Management
PPTX
SQL INJECTION
PDF
Learn to Leverage the Power of SOQL
PPTX
SOQL & SOSL for Admins
Apex Design Patterns
Apex Design Patterns
Creating a Data validation and Testing Strategy
Apex Enterprise Patterns: Building Strong Foundations
Query Optimization - Brandon Latronica
SLDS and Lightning Components
Aggregate function
Episode 20 - Trigger Frameworks in Salesforce
Salesforce Tutorial for Beginners: Basic Salesforce Introduction
Amazon Simpledb
Query optimization
Integrity constraints in dbms
SQL Queries
SQL(DDL & DML)
SQL Injection
CNIT 129S: Ch 7: Attacking Session Management
SQL INJECTION
Learn to Leverage the Power of SOQL
SOQL & SOSL for Admins
Ad

Similar to Episode 2 conditional flows & loops (19)

PPTX
Computer programming 2 Lesson 9
PPTX
Computer programming 2 - Lesson 7
PPTX
Salesforce Loop and Assignment Flows for Beginners.pptx
PPTX
Session 07 - Flow Control Statements
PPT
Control statements
PPTX
Flow of control by deepak lakhlan
PPTX
Control structures
PDF
Java input Scanner
PDF
Control statements anil
PPTX
Java basics and java variables
PPTX
Alternate for scheduled apex using flow builder
PPTX
Chapter4.pptxbwmwhwhwhwukwhwjwwjjwjwjwuw
PPT
Control All
PPT
slides03.ppt
PDF
Control flow statements in java web applications
PDF
Lecture 8
PPTX
Chapter 6 - More conditionals and loops
PDF
Compiler Construction | Lecture 10 | Data-Flow Analysis
Computer programming 2 Lesson 9
Computer programming 2 - Lesson 7
Salesforce Loop and Assignment Flows for Beginners.pptx
Session 07 - Flow Control Statements
Control statements
Flow of control by deepak lakhlan
Control structures
Java input Scanner
Control statements anil
Java basics and java variables
Alternate for scheduled apex using flow builder
Chapter4.pptxbwmwhwhwhwukwhwjwwjjwjwjwuw
Control All
slides03.ppt
Control flow statements in java web applications
Lecture 8
Chapter 6 - More conditionals and loops
Compiler Construction | Lecture 10 | Data-Flow Analysis
Ad

More from Jitendra Zaa (20)

PPTX
Episode 13 - Advanced Apex Triggers
PPTX
Episode 18 - Asynchronous Apex
PPTX
Episode 15 - Basics of Javascript
PPTX
Episode 23 - Design Pattern 3
PPTX
Episode 24 - Live Q&A for getting started with Salesforce
PPTX
Episode 22 - Design Pattern 2
PPTX
Episode 21 - Design Pattern 1
PPTX
Episode 19 - Asynchronous Apex - Batch apex & schedulers
PPTX
Episode 17 - Handling Events in Lightning Web Component
PPTX
Episode 16 - Introduction to LWC
PPTX
Introduction to mulesoft - Alpharetta Developer Group Meet
PPTX
Episode 12 - Basics of Trigger
PPTX
Episode 11 building & exposing rest api in salesforce v1.0
PPTX
Episode 14 - Basics of HTML for Salesforce
PPTX
South East Dreamin 2019
PPTX
Episode 9 - Building soap integrations in salesforce
PPTX
Episode 8 - Path To Code - Integrate Salesforce with external system using R...
PPTX
Episode 6 - DML, Transaction and Error handling in Salesforce
PPTX
Episode 5 - Writing unit tests in Salesforce
PPTX
Lightning Web Component in Salesforce
Episode 13 - Advanced Apex Triggers
Episode 18 - Asynchronous Apex
Episode 15 - Basics of Javascript
Episode 23 - Design Pattern 3
Episode 24 - Live Q&A for getting started with Salesforce
Episode 22 - Design Pattern 2
Episode 21 - Design Pattern 1
Episode 19 - Asynchronous Apex - Batch apex & schedulers
Episode 17 - Handling Events in Lightning Web Component
Episode 16 - Introduction to LWC
Introduction to mulesoft - Alpharetta Developer Group Meet
Episode 12 - Basics of Trigger
Episode 11 building & exposing rest api in salesforce v1.0
Episode 14 - Basics of HTML for Salesforce
South East Dreamin 2019
Episode 9 - Building soap integrations in salesforce
Episode 8 - Path To Code - Integrate Salesforce with external system using R...
Episode 6 - DML, Transaction and Error handling in Salesforce
Episode 5 - Writing unit tests in Salesforce
Lightning Web Component in Salesforce

Recently uploaded (20)

PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PDF
Business Ethics Teaching Materials for college
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
Complications of Minimal Access Surgery at WLH
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
RMMM.pdf make it easy to upload and study
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Institutional Correction lecture only . . .
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Basic Mud Logging Guide for educational purpose
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Business Ethics Teaching Materials for college
TR - Agricultural Crops Production NC III.pdf
Complications of Minimal Access Surgery at WLH
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
RMMM.pdf make it easy to upload and study
Renaissance Architecture: A Journey from Faith to Humanism
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Institutional Correction lecture only . . .
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
Pharmacology of Heart Failure /Pharmacotherapy of CHF
VCE English Exam - Section C Student Revision Booklet
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Basic Mud Logging Guide for educational purpose
102 student loan defaulters named and shamed – Is someone you know on the list?

Episode 2 conditional flows & loops