Apex Basics

Apex Basics and Database | Salesforce Apex Tutorial Guide

In this blog we’ll learn about Apex, Apex features, Features not supported by Apex, when to use Apex, Flows of Action, Apex Environments, and Tools for writing code in apex. This blog is going to be crisp and to the point for better understanding. 

So, Let’s take a quick look at Apex. 

Introduction 

  • Apex is a strongly typed language i.e., you need to specify the data type before initializing any variable or function. 
  • It is an object-oriented programming language that is developed by salesforce.com and owned by Salesforce itself.  
  • Developers can add business logic to system events like related record updates, button on-clicks, visualforce & lightning pages, etc. 
  • It is compiled and executed on the force.com platform servers. 
  • It is used for creating the SAAS apps on top of salesforce.com CRM functionality. 

Apex Features

  1. Its syntax is similar to Java. 
  2. Easy to use. 
  3. It is a not case-sensitive language. 
  4. Unlike other languages such as Java, Python, etc., Apex upgrades automatically. So, Apex doesn’t have upgraded versions like Java8, and 11. 
  5. Remember? There used to be the need of establishing connections with databases while working with Java. It’s already integrated with the database. So, Apex can access and manipulate records without an explicit DB connection 
  6. It has built-in support for executing test cases. So, easy to test as well. 
  7. Multi-Tenant Environment. 
  8. Its code can be saved against different versions of the force.com API. 

Feature loaded. Isn’t it? But there are some features that aren’t supported by Apex.  

dont miss out iconDon't forget to check out: Salesforce Apex Class | Salesforce Development | SFDC Development

Features not Supported by Apex

  1. Except for an error message, Apex can’t display the elements in UI. 
  2. It can’t build multiple threads. 
  3. You can’t use Apex to create a temporary file. 

When to Use Apex?

  • If you want to do transactions and rollbacks 
  • You may use it to create web & email services. 
  • You can perform complex validations over multiple objects. 
  • To do the processes that are not supported by workflows/flows/process builder. 

Flows of Action

  • Developer Action: When the code is being written & saved to the apex platform by the developer, the platform application server compiles code into a set of instructions (which can be understood by Apex run time), interprets, and then saves those instructions as compiled Apex. 
  • End-User Action: When this user performs any action involving Apex code or uses trigger, the platform application server fetches the instructions (compiled) from metadata and sends it via Apex runtime which interprets before returning the result. As compared to the standard application platform request, this user experience no differences in the execution time. 

dont miss out iconCheck out another amazing blog by Tanya here: Salesforce Flow - A Brief Guide You Should Check

Apex Environments

Apex can be executed in: 

  1. Developer org 
  2. Production org 
  3. Sandbox 

Tools of Writing Code in Apex

  1. Force.com Developer Console: You can write, test & debug the Apex code while using the Force.com developer console. 
  2. Code Editor in Salesforce Interface: Code editor in the user interface allow us to only write the code. It doesn’t support other features like debugging and testing. 

 

Responses

Popular Salesforce Blogs