Simple Deployment with the Force Platform IDE

,

The Force Platform includes two basic interfaces to the metadata that defines your objects and applications—the Force Platform Setup menu and the Force Platform IDE. You have seen how some declarative aspects of the platform are best addressed through the Force Platform Setup menu, while developing Apex code and, to some extent, Visualforce pages is best handled through the IDE.

So far, the process of development has focused on a single organization. Deployment in the Force Platform, by its very definition, is not about one organization, it is about moving configuration from one organization to another. This deployment process requires a tool that can log into two Force Platform organizations at once, via the Metadata API.

The Metadata API was introduced in Chapter 8: The Force Platform IDE as a mechanism for accessing and transporting metadata components from the Force Platform server to the Force Platform IDE. The Metadata API is used in a similar way to deploy an application from one organization to another. While it is possible to write your own Metadata API client to deploy an application, most Force Platform developers will want to leverage existing tools built for this purpose, such as the Force Platform Migration Tool and the Force Platform IDE.

Preparing For Deployment

Before you can get some hands-on experience deploying an application, you will need another Force Platform environment to be the target of the deployment.

Go to http://developer.force.com, the home page for Force Platform developers, and obtain a free Developer Edition account.

In order to properly deploy to another organization, you will need to connect to that organization with user credentials having the Modify All Data permission. In fact, you must have that permission in both the originating organization and the target organization.

Finally, you need to have adequate test coverage for any Apex code you want to deploy to a production organization. As described in Chapter 10: Apex, you must include test methods that exercise at least 75% of all of your Apex code to allow this code to be deployed. Some of the examples in earlier chapters did not include test methods in the implementations as described in the text, but all the sample code from the Code Share project does include a complete set of test methods and classes. If you choose to initialize your organization from the Code Share project, as described at the start of this chapter, your Apex code will have adequate test coverage. Refer to the Code Share project for additional information about test methods and classes for your organization.

All test methods and classes are run again as part of the deployment process, so if, for any reason, they fail, then the Metadata API will not allow the deployment.

Using the Force Platform Deployment Wizard

Now that you have a target organization defined, along with a user with proper permissions, you can use the Force Platform IDE to deploy a project to another organization.

Your first step is to create a project in the Force Platform IDE. If you have been reading this book from the beginning, you already have a Force Platform IDE workspace with a project. You should create another project for the deployment exercises of this chapter. If you are not familiar with using the Force Platform IDE, read Chapter 8: The Force Platform IDE, which provides an introduction to this key development tool.

1.
Open the Force Platform IDE.

2.
Create a project from your organization. Include all components in the following categories in the new project:

  • Applications

  • Classes

  • Homepagelayouts

  • Layouts

  • Objects-custom

  • Pages

  • Tabs

  • Triggers

as well as the User object from the Objects - standard category.

Voice of the Developer

If you look at the list of entries under any component type, and don’t see a component you know is present in the target org, you can click on the Refresh icon int this page to refresh the metadata which is used to generate these lists.

3.
Click OK to add the selected components to the request list.

4.
Click Finish to download the components to your new project.

Now that your project is loaded into your Force Platform IDE workspace, you can deploy the project to another server.

5.
In the Package Exporer, right click the src folder in your new project, and select the Force Platform Deploy to Server choice, which starts the deployment wizard.

The Force Platform IDE first checks to insure that the contents of the project and the server metadata on which the project is based are still in agreement. Once this check passes, you are prompted for a username, password and environment for your deployment target, as shown in the figure below.



Figure 226. Preparing to save a project


6.
Click Next. The IDE logs into the target organization and verifies your permissions.

In the second step, you are prompted to archive the setup already present in the destination, and to archive the content being deployed. Archiving is a good idea so you can remember when you’ve made changes, but also because the archives will be needed if at any time in the future you might want to reverse one or more of the changes.

7.
Select a directory for the destination archive and click Next.



Figure 227. Results of deployment plan calculation


8.
In the next panel, a deployment plan is calculated and displayed, as shown above.

The list in the dialog box covers all the deployment component candidates. Each component is shown in one of three colors, and each component has a check box to the left of the line, which indicates if the suggested action should be taken as part of this deployment.

If a candidate component is not present in the target organization, the entry is shown in green, indicating that the component will be added to the target organization. If the candidate component is present in the target organization, but the metadata for that component is identical to the metadata in the project, the entry is shown in grey, indicating that no action will be taken for this component. If the candidate component is present in the target organization with different metadata, the entry is shown in yellow, indicating that the component in the target organization will be overwritten with the new metadata. By default, all green and yellow entries are shown with the Action checkbox checked. You can uncheck that box for any candidate, as appropriate.

Before you deploy to a server, the Force Platform IDE checks to see if there are any components in the target organization which are not in the project you are deploying. You are given the option to delete these extra components, if you wish.

9.
Once you have reviewed the deployment plan and are satisfied with the choices, you can optionally perform a trial deployment by clicking Validate Deployment. This performs all the steps of the deployment plan, but without actually committing the changes. This action is recommended to check for deployment errors or confirm code coverage requirements are met, in advance of your actual deployment schedule.

Voice of the Developer

The Valid Deployment option performs the exact same set of actions that the deployment plan will, but without actually sending the project to the target server. The action is like a database update without a commit action. If the Validate Deployment reports any issues that can cause the deployment to fail, the deployment itself will not succeed, and deliver the same messages. Because of this, you will typically want to either do a Validate Deployment or an actual deployment—doing both is redundant.

If the validation of the deployment completes successfully, you are presented with another dialog that reports on the success. This report includes any statistics on the code coverage for Apex code included in the deployment. The dialog includes an option to view the log of the validation effort, which will have entries for the deployment of every individual component.

Remember that Apex cannot be saved into a production organization without a successful execution of test methods that achieve the required coverage level. The Validate Deployment option will check to make sure that the proper test coverage is in place, among other tests.

10.
When you are certain you wish to deploy this plan, you can click Next. The deployment proceeds and, if it is successful, the changes are saved to your destination organization. You will receive messages as to the results of the deployment in the final page of the Deployment Wizard, shown below.



Figure 228. The final page of the Force Platform IDE Deployment Wizard


11.
After this type of deployment, log into the target organization and check out the results of the deployment.

Keep in mind what has, and has not, happened. The deployment process from the Force Platform IDE moved the metadata for the components in the project to the new organization. This metadata controls the definition of the components in the package, in this case, most of the application you have been working on.

The deployment itself does not load any data into your organization. Use Data Loader to copy over any data required in the new organization.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.210.219