Introduction to Salesforce programming

  • (4.0)
  • | 127 Ratings |
  • Last Updated January 24, 2019

Introduction to Salesforce programming

Salesforce provides two modules, one is admin module and the other is developer module. A Salesforce developer can execute code and customise code, based on the client requirement. There are different platforms to work on programming. They include (developer platform), etc. Salesforce developer can be assigned to either front-end development or back-end development. Front-end development platforms include Apex and Visualforce. The back-end development includes SOQL.

Get ahead in your career by learning Salesforce through Mindmajix Salesforce Training.

Apex is the first language which runs on cloud/ internet. It is OOPS language which helps the developers to execute and transact statements via Lightning Platform server, with conjunction of calls to the API. It is similar to Java and perform database stored procedures. The code can be initiated via web service calls and triggers from objects. Apex allows developers to include business logic to the events included.

SOQL is a back-end source for Salesforce. It is used to read the records from the Salesforce. Salesforce also provides SOQL - Salesforce Object Oriented Language which is used to read the stored data.

Basically, we have 2 different modules in Salesforce:

  • Salesforce Administration.
  • Salesforce Developer.

Let us look into few scenarios where coding is important than administration in Salesforce. 

  • We have a requirement from the client that, whenever the record is modified, we need to send an email to the customer.

Hint: WFR(workflow rule).

  • We have a requirement from the client that, whenever the record is deleted, he/she should receive an automated email from the application.

Hint: It is not possible in configuration method, so we follow the coding method to fulfill this requirement from client side.

  • We have a requirement from the client that, connect Salesforce to .Net and pass data (simple communication).

Hint: Outbound message in the WFR (workflow rule).

  • We have a requirement from the client that, connect Salesforce to .Net but with some authentication, by using O-authorization (mechanism to connect from one platform to another by 2 step authentication).

Hint: This is not possible by Configuration method. It can be done programmatically.

[Related Page: Salesforce Tutorial For Beginners]

Current Market Trends:

According to USA market trends, Salesforce Administrator is paid 40 to 50 USD per hour, where as the Salesforce Developer is paid 80 to 90 USD per hour.

Learning Programming In Salesforce: 

Salesforce programming includes Apex, It is a strongly typed, OOP Language which allows developers to transact control statements on Salesforce servers. Apex is similar to Java and acts like DB stored procedures, It enables the developers for adding business logic for most system events. Code can be initiated with Web service requests & from triggers on objects.

How to become confident in Salesforce Development?

By following the below mentioned points, we can be confident in starting Salesforce Development.

  • What is programming ? / Basics of programming.
  • What is Salesforce programming ?
  • Need to understand medium & advance complexity scenarios in Salesforce programming.
  • Some project scenarios.

APEX: It is the world’s first language which can run on cloud/internet. We have different symbols in the programming to use, 

  • + , = , <=, >= , {, [, (.
  • Integer, String, Class, Trigger.

Statement example in Salesforce programming

integer age = 20;  -  whenever the statement is complete, it should end with a semicolon.

Group of statements: 

Let us assume few statements with values included in it.

Integer bonus = 20;
Integer salary = 3000;
Integer sum;
Sum = bonus + salary;

[Note: bonus, salary, sum are variables.]


The name given to the memory location where we store some data and used in the program, is called a variable. Why do we need to store data? - Without storing data, we cannot use the data for the future use.

Note: Every variable is first declared with the type of data it’s going to store. It is mandate to declare before we start using that variable.

Variable types in Salesforce

Integer = Number, (1, 10, 100,1000 etc)
String = Text data, ( sara, john etc)
Double = Fraction data. (1.2, 10.2, 234.235 etc)

Sample program for assigning values to the variables

Take 3 variables and assign values to it.

ClientName = &#39;Adam&#39;;
Age = 28;
Salary = 989.99;

Let us have a look into Salesforce Data Types: 

Salesforce data types includes primitive, collection & sObjects. These are classified based on their features.

  • Primitive - Integer, Double, Long, Date, Datetime, String, ID, or Boolean.
  • An sObject - An entire record of any Object can be saved in variable.
  • Collection - we can save large data together.

What is comment?

Commenting in the programming is quite common to understand what the statement specifies.
Comment can be given to single line or group of lines together.


  • // This programme defines sales logic(for single line)
  • /* Hai
    My name is John
    I am working with you */ (for multiple lines)

Frequently asked Salesforce Interview Questions & Answers


Operators are the symbols which operates on value or a variable. “ + “ - is an operator to perform addition.

  • Eg: Sum = Salary + Bonus;

Different types of Operators:

Apex has wide range of operators to perform various operations. Operators can be classified into different types for better understanding:

Arithmetic Operators: ( +, -, *, %, / )
Increment or Decrement Operators: (++, -- ) [eg: a=10; a++, result: 10 + 1 = 11]
Assignment Operator: ( = )
Relational Operators: (>= , <= , > , < )
Comparison Operators: ( == )
Logical Operators: (&& , || )


Combination of variable and operator is called an Expression (E= V+O).

Eg: Z = X + Y;

Clarification: This is to simplify the  above example in what it defines.

Variable  : X,Y,Z.
Operator : +, =.
Delimiter : ;

Ideal format of coding in Real-Time projects:

// Variable Declaration

Integer AgeOfJohn;
Integer AgeOfSara;
Integer SumOfAges;
Integer AgeOfJohnAfter5Years;

// Variable Initialisation

AgeOfJohn = 24;
AgeOfSara = 25;

// Business Logic

SumOfAges = AgeOfJohn + AgeOfSara;
AgeOfJohnAfter5Years = AgeOfJohn + 5;

Result : 

SumOfAges = 49
AgeOfJohnAfter5Years =29

Sample Programme for Addition & Multiplication

Consider 2 variables, perform Addition & Multiplication of both the numbers.

// Variable Declaration

Integer Product1;
Integer Product2;
Integer SumOfProducts;
Integer MultiplicationOfProducts;

// Variable Initialisation

Product1 = 20;
Product2 = 30;

// Business Logic

SumOfProducts = Product1 + Product2;
TotalProducts = Product1 * Product2;

Result : 

SumOfProducts = 50.
TotalProducts = 600.

[Related Page: How A Salesforce Certification Can Boost Your Career]

How to print the OutPut values of the program?

Let us assume with a sample program of Addition & Multiplication:

// Variable Declaration
Integer Product1;
Integer Product2;
Integer SumOfProducts;

Integer MultiplicationOfProducts;

// Variable Initialisation

Product1 = 20;
Product2 = 30;

// Business Logic

SumOfProducts = Product1 + Product2;
TotalProducts = Product1 * Product2;

// Output

Syntax system.debug();

system.debug(&#39;The Sum = &#39; + SumOfProducts );
system.debug(&#39;The Multiplication = &#39; + TotalProducts );

Now, let us execute the program in the Salesforce Environment:

Login to Salesforce Org → Click On the “UserMenu” → Select “Developer Console” → A new window opens → Click on (Ctrl + E)  or (Open Execute Anonymus Window) → Paste the code and Click on Execute (Check the box “OpenLog” for log wise result). The button next to Execute is  “Execute Highlighted” - If you need to execute some part of the code, you can select the Execute highlighted. 

Program in the Salesforce Environment

Program in the Salesforce Environment

The result is shown in a log based as shown in the below figure.

Program in the Salesforce EnvironmentProgram in the Salesforce Environment (a)

If you want to check only the OutPut and not all the log files, you need to select the “Debug Only” checkbox in the bottom line of the Execution Log.

Explore Salesforce Sample Resumes! Download & Edit, Get Noticed by Top Employers!Download Now!

Program in the Salesforce EnvironmentProgram in the Salesforce Environment(b)

In the next topics, we will discuss in detail about “”. Keep following us for more info on Salesforce Development / Programming.

Mindmajix offers different Salesforce certification training according to your desire with hands-on experience on Salesforce concepts

Subscribe For Free Demo

Free Demo for Corporate & Online Trainings.

About Author


Arogyalokesh takes complex technical ideas and distills them into user-friendly visuals to improve digital marketing campaigns for companies. He is a Content Writer at Mindmajix spreading nuggets of content related to Technology. Proceeded to work in a fast upscale environment, assuring client delight in content writings Protection Status