Salesforce Apex Environment

Salesforce Apex Environment

On September 27, 2021, Posted by , In Salesforce Apex Tutorial, With Comments Off on Salesforce Apex Environment
Salesforce Apex Tutorial - Chapter 2 - Apex Environment Image 1
Salesforce Apex Tutorial – Chapter 2 – Apex Environment

Table of Contents

Salesforce Provides Sandbox and Developer Editions organization to develop Apex Code, you can use either of them for apex code development. A sandbox is a replica of the production environment in which you can build and test your code before deploying it to the production environment as it reduces the risk of getting errors in production.

Sandbox Environment for Developing Apex code

It is a salesforce best practice to use the Sandbox environment for developing code and then deploy it to the Production environment. The operations you perform in your sandboxes are not reflected in your Salesforce production organization. Salesforce provides four types of sandboxes i.e,

  • Developer Sandbox.
  • Developer Pro Sandbox.
  • Partial Data Sandbox.
  • Full Sandbox.

Sandboxes are available per salesforce edition type; it depends on what edition you have.

SANDBOX TYPEPROFESSIONAL EDITIONENTERPRISE EDITIONUNLIMITED EDITIONPERFORMANCE EDITION
Developer Sandbox      1025100100
Developer Pro Sandbox55
Partial Copy SandboxNot Available111
Full SandboxNot Available11
Salesforce Apex Tutorial - Chapter 2 - Apex Environment Image 2
Deployment

Apex Code development tools: The following is a list of three tools that are available to develop apex code in all Salesforce editions.

  • Force.com Developer Console
  • Force.com IDE
  • Code Editor in the Salesforce User Interface

Let’s take a look at working of the Force.com developer console

What is Salesforce Force.com Developer Console? Explain

The Salesforce Developer Console is an integrated development environment (IDE) provided by Salesforce, offering a suite of tools and features that facilitate the development, debugging, and testing of Apex code, Visualforce pages, and Lightning components. It’s a web-based interface accessible directly from the Salesforce UI, providing a convenient and powerful platform for developers to write and manage their code. The Developer Console is particularly beneficial for its real-time debugging and performance data capabilities, allowing developers to execute and test code, view logs, and analyze resource usage and execution timelines.

Besides coding, the Developer Console provides valuable features for query optimization and data inspection. Developers can write and execute SOQL and SOSL queries directly within the console, inspecting the returned data or checking the efficiency of their queries. The console also offers advanced features like a detailed log inspector, a checkpoint feature for setting breakpoints and inspecting variable values in Apex code, and the ability to view the execution stack. These tools are essential for Salesforce developers aiming to build efficient, scalable, and bug-free applications on the Salesforce platform.

How to get started with force.com Developer Console?

A Developer Console provides a set of tools you can use to develop, debug, and test applications within your Salesforce organization. It is an integrated development part of the salesforce organization.

Following are the steps to be followed to use the developer console:

Go to Setup and click on developer console from the drop-down in lightning framework, It will open it in a new window as shown in the below pics:

Salesforce Apex Tutorial - Chapter 2 - Apex Environment Image 3
Salesforce Apex Tutorial – Chapter 2 – Apex Environment Image 3
Salesforce Apex Tutorial - Chapter 2 - Apex Environment Image 4
Salesforce Apex Tutorial – Chapter 2 – Apex Environment Image 4

Here’s a list of operations you can perform using the developer console.

  1. Code writing and compilation of code: you can create an apex class, trigger, lightning component or visualforce page, etc using the source code editor and as soon as you save your code it will automatically be compiled on the force.com server.
  2. Debugging: Apex supports debugging. Using the Developer Console and the debug logs, you can debug Apex code and also you can set checkpoints to make debugging easier.
  3. Testing: You can build and execute test cases for a specific apex class and also inspect the code coverage.
  4. SOQL/SOSL  queries: In the query editor tab you can perform both SOQL and SOSL queries.
  5. Color coding and autocomplete: In addition to auto-completion for class and method names, the editor uses a color scheme to make code elements easier to read.

Code execution steps in Developer Console:

Follow these steps to execute your code in the developer console.

Step 1: Open the Developer console from the setup.

Salesforce Apex Tutorial - Chapter 2 - Apex Environment Image 5
Salesforce Apex Tutorial – Chapter 2 – Apex Environment Image 5

Step 2: Click on Debug tab and select Open Execute Anonymous window  or press CTRL+E directly to open the anonymous window

Salesforce Apex Tutorial - Chapter 2 - Apex Environment Image 6
Salesforce Apex Tutorial – Chapter 2 – Apex Environment Image 6

Step 3: A new window will appear in which you can write or paste the code and execute it as a whole or a highlighted piece of code and tick the checkbox open log as shown in the below image.

Salesforce Apex Tutorial - Chapter 2 - Apex Environment Image 7
Salesforce Apex Tutorial – Chapter 2 – Apex Environment Image 7

Step 4: After clicking Execute OR Execute Highlighted, debug log will open in which you can get all the details of success or failure of code.

Salesforce Apex Tutorial - Chapter 2 - Apex Environment Image 8
Salesforce Apex Tutorial – Chapter 2 – Apex Environment Image 8
Salesforce Apex Tutorial - Chapter 2 - Apex Environment Image 8
Salesforce Apex Tutorial – Chapter 2 – Apex Environment Image 8

Above steps should be followed to execute your code using force.com developer console. 

Keyboard Shortcuts for a Salesforce Console in Salesforce Classic

  1. Ctrl + G / Cmd + G: Focus on primary tab search.
  2. Ctrl + Shift + T / Cmd + Shift + T: Open tabs menu.
  3. Ctrl + Shift + W / Cmd + Shift + W: Close current primary tab.
  4. Ctrl + Shift + [ / Cmd + Shift + [: Move to previous primary tab.
  5. Ctrl + Shift + ] / Cmd + Shift + ]: Move to next primary tab.
  6. Ctrl + Shift + L / Cmd + Shift + L: Open list of records for current tab.
  7. Ctrl + Up Arrow / Cmd + Up Arrow: Move up in a list.
  8. Ctrl + Down Arrow / Cmd + Down Arrow: Move down in a list.
  9. Ctrl + E / Cmd + E: Edit current record.
  10. Ctrl + S / Cmd + S: Save current record (in edit mode).
  11. Ctrl + Shift + X / Cmd + Shift + X: Close current subtab.
  12. Ctrl + Shift + U / Cmd + Shift + U: Open utilities pop-out.
  13. Ctrl + Shift + H / Cmd + Shift + H: Open history menu.

Developer console keeps showing “loading…” and crashes, how to resolve?

If you’re facing issues with the Salesforce Developer Console continuously loading or crashing, you can try a few straightforward solutions to resolve this problem. Start by clearing your browser’s cache and cookies, as accumulated data can sometimes lead to such issues. If that doesn’t work, try accessing the Developer Console in your browser’s incognito or private mode to bypass any cache or cookie problems.

Another step to consider is switching browsers. Compatibility issues are not uncommon, and using a different browser might instantly solve the problem. It’s also a good idea to check the Salesforce Trust website to see if there are any ongoing issues or maintenance activities that might be affecting Salesforce services.

Browser extensions can interfere with web applications, so consider disabling them to see if that resolves the issue. If the console is still not responding, try adjusting your browser’s script timeout settings, which can prevent the page from crashing due to long-running scripts.

Network connectivity can also be a culprit, so ensure that your connection is stable. If none of these steps work, check Salesforce’s known issues or reach out to their support team for assistance. As a temporary workaround, you might want to use alternative tools like Workbench or a third-party IDE for your immediate Salesforce development needs.

Unable to open developer console, how to resolve?

  1. Clear Browser Cache and Cookies:Clear your browser’s cache and cookies to remove any stored data that might be causing issues.
  2. Use Incognito/Private Mode:Open your browser in incognito or private mode and try accessing the Developer Console. This mode bypasses cached data and cookies.
  3. Switch Browsers:Try using a different browser to see if the issue is browser-specific.
  4. Check Salesforce Trust Site:Visit the Salesforce Trust site (trust.salesforce.com) to check if there are any service disruptions or maintenance activities.
  5. Disable Browser Extensions:Temporarily disable any browser extensions, as some can interfere with the functionality of web applications.
  6. Check Network Connectivity:Ensure your internet connection is stable. Sometimes, poor connectivity can cause loading issues.
  7. Consult Salesforce Known Issues:Look for your issue on Salesforce’s known issues page or forums. Others might have experienced the same problem and found a solution.

Top 5 Multiple Choice questions on Salesforce Developer Console for beginners

  1. What is the primary purpose of the Salesforce Developer Console?
    • A) To manage user profiles and permissions
    • B) To develop and debug Apex code, Visualforce pages, and Lightning components
    • C) To track sales and customer interactions
    • D) To customize the Salesforce UI
  2. Which feature in the Developer Console allows you to execute anonymous Apex code?
    • A) Query Editor
    • B) Test Execution
    • C) Apex Profiler
    • D) Execute Anonymous Window
  3. Which of the following can you use to view the debug logs in the Developer Console?
    • A) Log Inspector
    • B) SOQL Query Editor
    • C) Apex Test Execution
    • D) Schema Builder
  4. What can you use the Query Editor in the Developer Console for?
    • A) Creating and editing Visualforce pages
    • B) Writing and executing SOQL and SOSL queries
    • C) Monitoring and optimizing the performance of Apex code
    • D) Managing and deploying Lightning components
  5. In the Developer Console, what is the purpose of the Test Execution feature?
    • A) To deploy Apex code to production
    • B) To execute and monitor the performance of SOQL queries
    • C) To run Apex tests and view code coverage results
    • D) To track changes made to the Salesforce schema

Answers:

  1. Answer: B) To develop and debug Apex code, Visualforce pages, and Lightning components
  2. Answer: D) Execute Anonymous Window
  3. Answer: A) Log Inspector
  4. Answer: B) Writing and executing SOQL and SOSL queries
  5. Answer: C) To run Apex tests and view code coverage results

Before reading this tutorial, you can read Salesforce Apex Overview as first tutorial. You can read the Salesforce Apex Examples.

Comments are closed.