// Salesforce - Developer - Tools - Force.com IDE: A force.com project is a container that stores all metadata for a single username in Eclipse. Projects are made up of metadata pulled down from the server and stored locally. At the same time, changes are pushed back to the server. Most components from an org can be included in a project. Force.com IDE is a plugin for Eclipse. When you create a project, you are sometimes prompted for a new master password. This master password is a separate password of your choosing. It’s required by Eclipse secure storage but not associated with your Force.com IDE credentials. For information on Eclipse secure storage, see the Eclipse Workbench User Guide. We can use the Force.com IDE to: 1. Test and debug Apex classes and triggers. 2. Run anonymous blocks of Apex on the server. 3. Browse schema objects and fields or assemble and execute SOQL queries. 4. Synchronize project contents with changes on the server using 1. Save to Server 2. Refresh from Server 3. Synchronize with Server commands. 5. Utilize the Compare Editor to merge changes when conflicts are detected. 6. Deploy metadata components from one Salesforce organization to another, or validate a planned deployment without saving changes, using the Deploy to Server wizard. 7. Create or edit the package.xml project manifest file using the Choose Metadata Components dialog. 8. Develop in your project and on the server at the same time, with multiple developers accessing the same information. The Force.com IDE allows you to create and edit Apex, Visualforce, and XML metadata components. The Force.com IDE’s source code editors provide syntax highlighting, code assistance, and server-based error checking. The Force.com IDE is based on the Tooling API. Much of the actual work, such as compilation, happens on the Force.com platform—the Force.com IDE performs the communication and result parsing transparently. The package.xml file, also known as the project manifest, is a control file that determines the set of metadata components to retrieve or deploy in a project. If you are looking at the Package Explorer, this file is located in the src folder. In practice, it is much easier to use the Project Properties dialog to add or remove components from a project—which modifies package.xml for you—but it is also possible to edit package.xml by hand. If your Force.com project is associated with a particular server-side package (as specified in the <fullName> element), the server determines what components are listed in package.xml and any user changes to the file will be overwritten. Increase your productivity by reducing the time required for saving the projects in offline mode, which is the default setting. By default, Force.com IDE creates projects in offline mode. When we work in offline mode, we avoid compiling our Apex code each time we save the files. However, if we have a stable Internet connection and a small-to medium-size code base, consider using online mode. When working online, the files that we save are saved on the server, and then retrieved from the server to our project. When working offline, files are saved locally. We can however, save files to the server when we right click the file in the Package Explorer and choose "Force.com -> Save to Server" This action is the same as when we save files while working online. Inside the src folder, there may be a folder named "Referenced Packages". This folder contains the contents of any managed packages that are installed in the home org. These files are read-only. Customizing installed managed packages using the Force.com IDE is not supported. Use the Force.com IDE's Project Properties dialog to modify existing project. We can update credential, connection settings, change the included metadata components, and adjust view settings. To open the Project Properties dialog, right click on the project and select "Properties" // To install Force.com IDE for Eclipse: 1. Verify Java version installed on your Computer 1. Launch a terminal / command line window 2. Run "java -version" 2. Install Java (if required) 3. Install Eclipse 4. Install Force.com IDE in Eclipse 5. Connect to Salesforce Org from Force.com IDE The first step is to create a Force.com project associated with your Salesforce org (the home org) and download metadata components. You can manage projects and files using the standard views, tools, and commands in the Eclipse IDE workbench, and use features from the Force.com IDE. See http://sforce.co/2jW1RVZ // To create a new project: 1. Launch Eclipse 2. Change to the Force.com Perspective 3. Click on File -> New -> Force.com Project 4. Provide a name for the project, username, password, security token. Do not change endpoint (leave this option uncheck). Click Next. 5. On the Project Content page, choose Apex and Visualforce 6. Click Finish. Connect the project to the associate org, copy components from the home org into the project in the appropriate folders. // To create an Apex class: 1. Right click on the project 2. Select New -> Apex Class 3. Give the class a name 4. Click Finish 5. Provide the detail implementation for the class // To edit an Apex class: 1. double click on the name of the class in the Package Explorer pane. 2. Modify the source code 3. Click on the Save button. Force.com IDE will save your change to your org. // To create a trigger: 1. Right click on our project in the Package Explorer and select File -> New -> Apex Trigger 2. Provide the name for the trigger 3. Click on the Object drop-down list and select the appropriate object 4. In the Apex Trigger Operations section, check appropriate check boxes 5. Click Finish 6. Provide the concrete implementation (source code) for the trigger 7. Click on the Save button // To execute Apex unit tests: 1. Select "Run -> Run Configuration -> Apex Test -> New launch configuration" 2. Select the "Test" tab 3. Select the tests that we wish to run. First select the class that contains the test methods that we wish to run, and then select the methods that we wish to run. To create and run test suites, select "Use suites", and then select one or more test suites. 4. Click Apply. 5. Click Run. // To create a test suite: 1. Right click on our project and select "New -> Apex Test Suite" // To edit a test suite: 1. Edit the /src/testSuites/YourTestSuite.testSuite file (XML file) Apex test suites are represented in Metadata API as ApexTestSuite components. Unlike the Developer Console, which color-coded both covered and uncovered lines, the Force.com IDE highlight only the lines of code that still need coverage. Lines containing the ternary operator are not considered as covered unless both conditions has been tested. // To toggle between offline mode and online mode: 1. Right click on our project in the Package Explorer 2. Choose Force.com 3. Select the mode that we want to work in. // To run SOQL queries: 1. Double click on salesforce.schema in the Package Explorer pane 2. Enter your SOQL query in the text box 3. Click the "Run Me" button // To add existing components in your home organization to a project: 1. In the Package Explorer, right-click the project and choose Properties. 2. In the Project Properties dialog, expand the node for Force.com and click Project Contents. 3. Click Add/Remove Metadata Components to open the Choose Metadata Components dialog. Because a Force.com project is connected to its home organization, simply deleting a metadata file from a project does not always permanently remove it. Depending on whether your intention is to delete a component from the home organization as well as your project, or merely to exclude it from your project, the steps you take are different. If you remove a component from a project without deleting it from the server, you can add it to your project again. The component will also be available in other projects that connect to the same server. If you delete the component on the server, the component will not be accessible from other projects. The only way to retrieve it again is by using the web interface and viewing your Recycle Bin. To remove a component from the project only: 1. In the Package Explorer, right-click your project and choose Properties. 2, In the Project Properties dialog, expand the Force.com node and click Project Contents. 3. On the Project Contents page, click Add/Remove Metadata Components. 4. Use the Choose Metadata Components dialog to remove the component. 5. In the Package Explorer, expand the nodes to find the component you want to remove. The project will no longer download the component from your home organization during synchronization, but you still need to delete your local copy of the file. 6. In the Package Explorer, right-click the component and choose Delete. 7. When you’re prompted whether you want to delete the file, click Yes to remove the local copy. 8. In the Remote Delete Confirmation dialog, you’re prompted whether to also delete the component on the server. Click No to leave the server-side component unaffected. To remove a component from the project and delete it from the server: 1. To delete files both locally and on the server, make sure that you’re working online. Right-click your project in the Package Explorer, and then select Force.com | Work Online. 2. In the Package Explorer, expand the nodes to find the component you want to delete. 3. Right-click the component and choose Delete. 4. When you’re prompted whether you want to delete the file, click OK to remove the local copy. 5. Finally, in the Remote Delete Confirmation dialog, you’re prompted whether to also delete the component on the server. Click Yes to delete the component entirely. // To view a component's properties: We can use the Component Properties dialog to view the server properties of a metadata component such as its name, type, status, package, namespace, and the date the file was created and last modified. To view Component Properties: 1. In the Package Explorer, locate the component that we want to view. 2. Right click on the component and choose Properties 3. Click "Force.com Component" in the navigation pane on the left side of the properties dialog // Synchronization: When we create a Force.com project, the files we specify in our project manifest are copied from the server, and stored locally on our computer. The term project refers to the local files on our computer, while the term server refers to the live metadata components in our Salesforce org. As we develop in the IDE, and make changes to the metadata files in our project, it is possible that someone else may make change to the metadata components directly in the org via the browser. If we are working in a team-based environment, other developers may make changes in the source files in our shared repository. In either cases, when metadata is changed outside of our project, our project is not immediately aware of those changes, and our files may be out of sync. There are 3 actions that we can take to keep our project and organization files in sync. All of these actions are available by right-clicking the project src folder and choosing Force.com: 1. Save to Server 2. Refresh from Server 3. Synchronize with Server If we receive a save error that updates only your local instance (our local project or source control repository), this indicates that our file are not in sync with the server. To replace project files with server definition, use the "Refresh from Server". To push project files to the server, use the "Save to Server" option. The "Refresh from Server" option refreshes only the content specified in the package.xml file. If a file in our project is removed from package.xml, we will no longer receive the new version of that file. The "Synchronize" view sometimes does not recognize items in the home org that are not in the project. In these cases, right click the project name and select "Force.com -> Refresh from server" to refresh the components in our project. // To update the Force.com IDE: It is recommended that we always use the latest version of Force.com IDE so that we have the latest features, bug fixes, and documentation. To update the IDE: 1. From Eclipse, select "Help -> Software and Workspace Center" 2. The "Software and Workspace Center" opens, search automatically, and provides a link to any relevant updates in the "Updates Available" section. 3. Select the Force.com IDE update and click "Apply 1 change" 4. In the dialog that opens, confirm that the Install Location is correct and click Update. 5. Accept the license agreement and click Finish. 6. We are prompted to restart Eclipse. Click OK. 7. After we updated the Force.com IDE, we need to upgrade our projects to the latest version. See below. // To upgrade our project: When we create a Force.com project, it's designed to work with specific version of the server. When the server is upgraded to the next version, we need to upgrade our project so that we can have access to the latest features and metadata. To upgrade a Force.com project: 1. Right click on the appropriate project and choose "Force.com -> Upgrade Project" to open the Project Upgrade wizard. This option only appears if an upgrade is available. 2. Review the information on the first page of the wizard and click Next. 3. On the second page of the wizard, review the full details of what will be changed. If we do not want to upgrade all of these components, click Cancel. Otherwise, click Finish. 4. On the final page of the wizard, review your changes. 5. Click Finish to retrieve the specified components. // Field-Level Security Warning: Including both objects and profiles in your project will cause profiles to contain field-level security for all of that object's fields. The settings in your project will overwrite field-level security settings on the server when the profiles are deployed. If you are developing in a sandbox where field-level security is not set up correctly, and you deploy to a production organization, you will overwrite the field-level security in the production organization. To prevent overwriting production field-level security, do one of the following: 1. Do not include profiles in your project 2. Only choose object fields for which you want to overwrite the field-level security 3. Make sure your sandbox security settings are exactly the same as your production org. // Execute Anonymous Using System.debug() The Force.com Execute Anonymous view allows us to execute an anonymous block of Apex. Anonymous blocks help us to quickly evaluate Apex on the fly. The content of anonymous block can include user-defined methods and exceptions. It cannot include the keyword static. We do not need to manually commit database changes made by anonymous code block. If our anonymous code block complete successfully, any database changes are automatically committed. If our anonymous code block fails, any changes made to the database are rolled back. After our anonymous code block is executed on the server, the Results area in the Execute Anonymous view will display the following: 1. Status information for the compile and execute phase of the call, including any errors that occur. 2. The debug log content, including the output of any calls to the System.debug method. 3. The Apex stack trace of any uncaught exceptions, including the class, method and line number of each call stack element. Unlike classes, and triggers, anonymous blocks are executed as the current user and can fail to compile if the code violates the user's object, and field-level permissions. System.debug() is a special method that you can add to your code to generate output when code is executed to provide feedback for the developer. For example, System.debug('The value of x is:' + x); Execute Anonymous is a screen where you can write code and run code. This code is not saved anywhere. To use Execute Anonymous, look for it in the bottom pane in Eclipse Force.com IDE. You can click on the Execute Anonymous tab, and click on the maximize icon. // Miscellaneous information: If our views or perspective is out of order, click on Windows -> Reset Perspective.