Posted in APEX

Salesforce : What is Apex ?

APEX in Salesforce

images (2)

apexLogo images (3)

Apex is a strongly typed, object-oriented programming language that allows developers to execute flow and transaction control statements on the platform server in conjunction with calls to the API. Using syntax that looks like Java and acts like database stored procedures, Apex enables developers to add business logic to most system events, including button clicks, related record updates, and Visualforce pages. Apex code can be initiated by Web service requests and from triggers on objects.


Apex provides built-in support for common platform idioms, including:

1. Data manipulation language (DML)

  • Insert
  • Update
  • Delete
  1. Soql and Sosl (To return records and search records)
  2. Looping that allows for bulk processing of multiple records at a time
  3.  Custom public API calls that can be built from stored Apex methods

Apex is:


  • Easy to use
  • Data focused
  • Hosted
  • Multi-tenant aware
  • Easy to test
  • Version-ed

How Does Apex Work?



Where to write Apex?

 images (6) images (4)

  • The com IDE is a plug-in for the Eclipse IDE
  • For a trigger on a standard object, from Setup, click Customize, click the name of the object, and click Triggers. In the Triggers detail page, click New and then enter your code in the Body text box.
  • For a trigger on a custom object, from Setup, click Develop Objects, and click the name of the object. In the Triggers related list, click New, and then enter your code in the Body text box.
  • For a class, from Setup, click Develop Apex Classes. Click New, and then enter your code in the Body text box.

Note: You cannot make changes to Apex using the Salesforce user interface in a Salesforce production organization.

images (5)

When Should I Use Apex?

  • Create Web services.
  • Create email services.
  • Perform complex validation over multiple objects.
  • Create complex business processes that are not supported by workflow

Language Constructs:

The following language constructs form the base parts of Apex:

  • Data Types
  • Variables
  • Expressions
  • Assignment Statements
  • Conditional (If-Else) Statements
  • Loops
  • SOQL and SOSL Queries
  • Exception Statements



Primitive Data Types:

  • Apex primitive datatypes include:
    • Boolean
    • Date

Apex uses the same primitive data types as the SOAP API. All primitive data types are passed by value


Local variables are declared with Java-style syntax. For example:


String str;

Account a;

  • Note: Multiple Variable can initialized in a single statement  Integer i,j,k;

Case Sensitivity:

Apex is Case In Sensitive.

  • Variable and method names are case insensitive.
  • References to object and field names are case insensitive.
  • SOQL and SOSL statements are case insensitive.


Account[] accts = [Select ID From Account where Name=’salesforce’]

images (1)

Exception Statements:

Apex uses  exceptions to note errors and other events that disrupt the normal flow of code execution. Throw statements can be used to generate exceptions, while  try, catch , and  finally can be used to gracefully recover from an exception.



Code block ;//Dml Insert



Code block;//Dml Exception





Hi! I am Pritam Shekhawat, Salesforce MVP. I am working as a 3x Certified Salesforce developer as well I am a co-leader of Noida Salesforce user group. Most important thing which I like about Salesforce is giving back. There aren’t enough words in the dictionary to describe the significance of giving back.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s