Blog

Introduction to Salesforce programming

  • (4.0)
  • | 1260 Ratings
Introduction to Salesforce programming

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 customize code, based on the client requirement. There are different platforms to work on programming. They include force.com (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.

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 the conjunction of calls to the API. It is similar to Java and performs 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 a few scenarios where coding is important than the 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 the 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 (a mechanism to connect from one platform to another by 2 step authentication).

Hint: This is not possible by the 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, whereas 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 a few statements with values included in it.

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

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

Variable

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 future use.

Note: Every variable is first declared with the type of data it’s going to store. It is mandated 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 = 'Adam';
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 Object - An entire record of any Object can be saved in a variable.
  • Collection - we can save large data together.

What is the comment?

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

Eg: 

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

Frequently asked Salesforce Interview Questions & Answers

Operators

Operators are the symbols which operate 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: (&& , || )

Expression

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('The Sum = ' + SumOfProducts );
system.debug('The Multiplication = ' + TotalProducts );

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

Log in 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 Environment

Program 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 Environment

Program in the Salesforce Environment(b)

In the next topics, we will discuss in detail about “Controlling the program flow in Salesforce”. 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.

Arogyalokesh
About The Author

Arogyalokesh is a Technical Content Writer and manages content creation on various IT platforms at Mindmajix. He is dedicated to creating useful and engaging content on Salesforce, Blockchain, Docker, SQL Server, Tangle, Jira, and few other technologies. Get in touch with him on LinkedIn and Twitter.


DMCA.com Protection Status

Close
Close