Apex is a strongly typed, object-oriented programming language. Apex allows developers to execute flow and transaction control statements on the Lightning platform server in conjunction with calls to the Lightning Platform​ API. Writing Apex code makes valuable Salesforce tools available.

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.

Writing Apex Code

Apex is more similar to Java than javascript. 

There are different types of tools are available to write the code in Apex:

  • Developer Console. The developer console is an integrated development environment with a collection of tools that we can use to create, debug, and test applications in our Salesforce org.
  • Visual Studio Code. 
  • Code Editor in Salesforce Interface.
Writing Apex code

How do you open the Apex code?

Click Debug | Open Execute Anonymous Window to open the Enter Apex Code window and to open the code editor in a new browser window. To automatically open the resulting debug log when execution is complete, select Open Log. Note You can’t use the keyword static in anonymous code.

The Developer Console

There are several development environments for developing Apex code. The Developer Console and the Salesforce extensions for Visual Studio Code allow you to write, test, and debug your Apex code. The code editor in the user interface enables only writing code and doesn’t support debugging.

The Developer Console is an integrated development environment with a collection of tools you can use to create, debug, and test applications in your Salesforce organization.

The Developer Console supports these tasks:

  • Writing code—You can add code using the source code editor. Also, you can browse packages in your organization.
  • Compiling code—When you save a trigger or class, the code is automatically compiled. Any compilation errors will be reported.
  • Debugging—You can view debug logs and set checkpoints that aid in debugging.
  • Testing—You can execute tests of specific test classes or all tests in your organization, and you can view test results. Also, you can inspect code coverage.
  • Checking performance—You can inspect debug logs to locate performance bottlenecks.
  • SOQL queries—You can query data in your organization and view the results using the Query Editor.
  • Color coding and autocomplete—The source code editor uses a color scheme for easier readability of code elements and provides autocompletion for class and method names.
Related Posts
Why Your Company Isn’t Like a Baseball Team
public sector and tribal governent

Recently, Chris shared an excellent post about the new World Series Champion Houston Astros. In short, it was a reminder Read more

Why We Love Pie But Not Pie Charts
Pie Chart

At Tectonic, we help you align your desired business results with the events and activities in your business. Everybody loves Read more

Salesforce Quickstarts
Salesforce Quickstart

What are Salesforce Quickstarts? Salesforce Quickstarts are ideal for individual departments or small sales and customer services teams looking to Read more

Salesforce SOAP API
Salesforce SOAP API

Salesforce provides programmatic access to your org’s information using simple, powerful, and secure application programming interfaces (APIs). Before reading more Read more