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.
- 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.
- Its syntax is similar to Java.
- Easy to use.
- It is a not case-sensitive language.
- Unlike other languages such as Java, Python, etc., Apex upgrades automatically. So, Apex doesn’t have upgraded versions like Java8, and 11.
- 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.
- It has built-in support for executing test cases. So, easy to test as well.
- Multi-Tenant Environment.
- 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.
Don't forget to check out: Salesforce Apex Class | Salesforce Development | SFDC Development
Features not Supported by Apex
- Except for an error message, Apex can’t display the elements in UI.
- It can’t build multiple threads.
- 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.
Apex can be executed in:
- Developer org
- Production org
Tools of Writing Code in Apex
- Force.com Developer Console: You can write, test & debug the Apex code while using the Force.com developer console.
- 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.