In our previous post we talked about What is Apex Programming. Now today we will discuss about Apex environment for Salesforce Apex development.
Writing Apex Code Using Sandbox Environments
Apex code can be developed in either Sandbox or Developer edition of Salesforce.
You can run Apex in a:
- developer org—An org created with a Developer Edition account
- production org—An org that has live users accessing your data
- sandbox org—An org created on your production org that is a copy of your production org
How to Create Code using Sandbox Org Apex environment
Steps to create a sandbox org:
- From Setup, enter Sandboxes in the Quick Find box, then select Sandboxes.
- Click New Sandbox.
- Enter a name and description for the sandbox.
- Select the type of sandbox you want.
- Select the data to include in your Partial Copy or Full sandbox.
- For a Partial Copy sandbox, click Next, and then select the template you created to specify the data for your sandbox.
- For a Full sandbox click Next, and then decide how much data to include.
- To include template-based data for a Full sandbox, select an existing sandbox template.
- To include all data in a Full sandbox, choose whether and how much field tracking history data to include, and whether to copy Chatter data.
- To run scripts after each create and refresh for this sandbox, specify the Apex class you previously created from the SandboxPostCopy interface.
- Click Create.
Writing Apex Code Using Development Environments
- The Force.com Developer Console and the Force.com IDE 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.
Force.com Developer Console
Force.com Developer Console integrated development environment with a collection of tools you can use to create, debug, and test applications in your Salesforce organization.
Steps to Open Developer Console
- Step 1: Go to Name->Developer Console (On Top right corner)
- Step2: Click on “Developer Console”
The Developer Console supports these tasks:
- Writing code
- Compiling code
- Checking performance
- SOQL queries
- Color coding and autocomplete
The Force.com IDE is a plug-in for the Eclipse IDE. The Force.com IDE provides a unified interface for building and deploying Force.com applications.
Install the Force.com IDE Plug-In
- Launch Eclipse and select . Click Add.
- In the Add Repository dialog, set the name to Force.com IDE and the location to https://developer.salesforce.com/media/force-ide/eclipse45. For Spring ’16 (Force.com IDE v36.0) and earlier Force.com IDE versions, use http://media.developerforce.com/force-ide/eclipse42. & Click OK.
- Select the Force.com IDE plug-in, and then click Next.
- In the Install Details dialog, click Next.
- In the Review Licenses dialog, accept the terms and click Finish.
- Eclipse downloads and installs the Force.com IDE and the required dependencies. When the installation is complete, you are prompted to restart. Click Yes.
- When Eclipse restarts, select . Select Force.com and then click OK.
How to use Apex Code Assist in Apex environment
To use code assist:
- Insert the cursor in the editor area.
- If you are typing a class or variable name, type a dot (“.”) and pause for a moment, and the proposal window opens.
- Select an item from the list & press Enter.
Solutions to Problems while Installing Force.com IDE
No Repository Found
Configure Eclipse to use your proxy server. You can find these settings in your Eclipse Preferences under.
2. No Force.com Perspective (macOS)
Download the full version of the Java SE Development Kit (JDK) from the Java download page.
3. No Force.com Perspective (Windows)
Add the explicit path to the JRE in the eclipse.ini file located in the directory where you installed Eclipse. Add this line:
-vm <full path to your jre>\javaw.exe