Introduction to Apex

Episode 1 – Introduction to Apex (Part 1)

Apex, Apex Hours for Students, Salesforce Developer Training

So, you have decided to commence your journey as a Salesforce developer and put your career in the fast-paced lane. Join us as you embark on this wonderful journey to become a champion Salesforce developer. In this module we will introduce the Salesforce platform and acquaint the attendees with Apex.


  • Declarative Vs Programmatic Approach of Development
  • Datatypes in Apex
  • Operators in Apex
  • System.Debug()
  • Familiarizing to Dev Tools – VS Code, Anonymous Block
  • Q & A

Most importantly don’t break a leg if you are overwhelmed with the pace of the live sessions. All Apex Hours for Student sessions will be recorded and will be available on our YouTube channel. Please Subscribe our YouTube Channel.

Here is Keynote from our session

Why code?

  • Customized applications
  • Tailored organization processes
  • Collaboration with external systems
  • Custom logic
  • Complex validation

What is Apex?

Strongly typed, object-oriented programming language that allows developers to execute flow & transaction control statements on Salesforce servers in conjunction with calls to the API.

How Apex Works
How Apex Works

Salesforce Application Anatomy

Data Types in Apex

Data Type Description Sample Value
Blob (Binary Large Object) Binary data stored as a single object. You can convert this data type to String or from String using the toString() and valueOf() methods, respectively.  VGhpcyBEb2N1bWVudCBjb250YWlucyBzYW1wbGUgdGV4dCBmb3IgdGhlIFZpc3VhbGZvcmNlIA0KRG9jdW1l
Boolean Logical value True, False, null
Date Indicates a particular day. Unlike Datetime values, Date values contain no information about time.  2020-02-10
Datetime A value that indicates a particular day and time, such as a timestamp. 2020-02-10 07:29:09
Time A value that indicates a particular time.  22:40:36.003Z
Decimal A number that includes a decimal point. Decimal is an arbitrary precision number. Currency fields are automatically assigned the type Decimal. 27.0

Variables in Apex

Variables are in-memory containers that can hold data belonging to a specific data-types during processing and can be reused based on their scope.

Integer inValue = 27;
System.debug(‘ID :’ +inValue);

Demo 2: Using Variables & Operators in Apex

String o = ‘Hello World’; //String
System.debug(‘Blob: ‘ + Blob.valueOf(o)); //Blob

Boolean isActive = true;
System.debug(‘Boolean: ‘ + isActive); //Boolean
System.debug(‘Date: ‘ + Date.newInstance(2020, 01, 18)); //Date

Datetime currDateTime =;
System.debug(‘Date: ‘ + currDateTime); //DateTime
System.debug(‘Time: ‘ + Time.newInstance(22, 40, 36, 03)); //Time

Decimal decValue = 27.01;
System.debug(‘Decimal: ‘ + decValue); //Decimal

Id recordId = [Select Id From Account Limit 1][0].Id;
System.debug(‘ID: ‘ + recordId); //ID

Integer intValue = 27;
System.debug(‘Integer: ‘ + intValue); //Integer

Long longValue = 2147483648L;
System.debug(‘Long: ‘ + longValue); //Long

Object objValue = o;
System.debug(‘Object: ‘ + objValue); //Object

Iterating Collections in Apex

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}

Conditional Statements in A

  • If Else…
  • Switch Statements
  • Ternary Operators

Collection in Apex

We have all below collection option in apex. Please check this post to learn more about collection in Apex.

  1. List
  2. Set
  3. Map

Demo 3 – Using Collections in Apex

List<Integer> listOfNumbers = new List <Integer> ();
System.debug(‘listOfNumbers: ‘ + listOfNumbers);

Set<Integer> setOfNumbers = new Set<Integer>();
System.debug(‘setOfNumbers: ‘ + setOfNumbers);

Map <Integer,String> mapOfIntegerString = new Map <Integer,String> ();
mapOfIntegerString.put(1, ‘one’);
mapOfIntegerString.put(2, ‘two’);
mapOfIntegerString.put(3, ‘three’);
mapOfIntegerString.put(3, ‘four’);
System.debug(‘mapOfIntegerString: ‘ + mapOfIntegerString);
System.debug(‘Value at 3: ‘ + mapOfIntegerString.get(3));

Demo 4 – Using Loops in Apex

List<integer> listOfNumbers = new List <integer> ();
Integer maxListSize = 5;
for(Integer i = 1; i <= maxListSize; i++){
System.debug(‘listOfNumbers: ‘ + listOfNumbers);

When should I use Apex?


Here is link of recording

Episode 1 will be presented by Jigar Shah on Feb 10, 2020 at 6 PM Indian Standard Time.

Further Learning

Apex Hours TrailMixes


Complete below assignment to win $1000 Salesforce Voucher. Click here for rule.

Write an Apex program to store all the numbers in a List starting from 1 until 20. Only numbers stored at even positions in the List should be added to get their sum which should be output to the Debug Log.

(Hint: Use a while loop and if else along with System. debug()

Don’t forget to register for our next session. Check this post for all other session details.

Please note that we have limit of 500 attendees that can join the online sessions. However, recording will be posted on our YouTube channel. Make sure to subscribe our YouTube channel to get notification for video upload.

So, learn at your pace and free will and ace your journey to Salesforce!


17,762 total views, 76 views today


Leave a Reply