In Salesforce, there are couple of ways to move metadata between environments. Here we are going to learn about Change Management which consists of 10% in Salesforce Advanced Adminstrator Exam. Without further ado, let's get into it!
NOTE: This post is written in April 2019 and content might be changed/updated overtime. The content is inspired by focusonforce.com.
Deployment Options
- When moving metadata between environments, there are certain possible of
source
andtarget
environments:Developer Edition
->Developer Edition
- Related
Sandbox
-> RelatedSandbox
- Related
Sandbox
-> RelatedProduction
- Unrelated Org -> Unrelated Org
Change Sets
Change Sets
is the most common way to deploy metadata between related sandbox/production org throughdeployment connection
.- Steps to deploy metadata with
Change Sets
:- Specify
Allow Inbound Changes
orAccept Outbound Changes
in SetupDeployment Settings
. (required to specify in both source and target organization)
- Navigate to
Outbound Change Sets
and create a newChange Set
.
- Add
Change Set Components
to be deployed.
- Upload to desired target organization.
- After finished uploading, navigate to target organization Setup
Inbound Change Sets
. You can find the newly createdChange Set
inChange Sets Awaiting Deployment
section. - You can click
Validate
to check for validation orDeploy
if you are ready to deploy. - You can monitor the status of
Change Set
deployment atDeployment Status
page. If deployment failed, you can clickView Details
to find out the error that causes the failure.
- Specify
- NOTE: if you are uploading custom code based components such as
Apex
classes orApex
triggers, you will need to provide test case(s) that cover(s) at least 75% code coverage of the uploaded components. - The available test options for
Change Sets
include:- Default - all local tests (no tests in sandbox)
- Run Local Tests - all tests except those from installed managed packages
- Run All Tests - all tests
- Run Specified Tests - only specified test class name separated by comma
,
not break line!
- Special notes regarding to
Change Set
:- once the
Change Set
components are uploaded, you will not be able to modify theChange Set
components anymore. - the whole transaction will be rolled back if deployment is failed.
Add Profiles
can be used to include profile settings such as custom object and field permissions. (the role, permission sets and etc. can be added viaChange Set
components)Change Set
cannot be used to rename or remove components.- dependent components might require separate deployment (cannot deploy all at once)
- not all metadata types are supported by
Change Set
(perform manually). For example,account teams
,quote templates
,web-to-lead
, and etc. - Supported components in
Change Set
(to name a few):- App
- Apex
- Approval Process (order of active approval process is not included and custom fields on standard project in approval page fields need to be manually added to a
Change Set
) - Assignment Rule / Auto Response Rule / Matching Rule / Duplicate Rule
- Custom Data Type / Custom Field /
- Custom Label / Setting / Report Type / Metadata Type / Object and etc.
- Compact Layout / Page Layout / Home Page Layout / Lightning Page
- List View
- Queue
- Permission Set / Role / Sharing Criteria Rule
- Report / Dashboard / Reporting Snapshot
- Validation Rule
- Visualforce Page / Component
- Workflow Rule / Task / Field Update / Email Alert / Outbound Message
- and etc.
- once the
Force.com IDE
Force.com IDE
is anEclipse
plugin that is mostly used by developers for local development and deployment.- It can be used to deploy components to any org, including an unrelated org. For example, metadata components can be deployed from
Developer Edition
toProduction
org. - Metadata components can be deleted from an org using
Force.com IDE
. - Use of
Deploy to Server
wizard:
- Enter Destination Details
a. Username (user must haveModify All Data
permission)
b. Password
c. Security Token (needed if used by user)
d. Environment (Production/Developer Edition, Sandbox, Pre-Release, Other)
- Specifying Archive Options - define project and destination archives in case something went wrong that requires a recovery later
- Deployment Plan - select list of items that needs to be deployed (add, delete, overwrite or take no action on components)
Validate Deployment
is used to perform test of selected components to destination (no changes committed)
- Deployment Result - indicate whether the deployment is success or not.
- Enter Destination Details
Force.com Migration Tool
Force.com Migration Tool
is a Java/Ant-based CLI for moving metadata between local directory and a Salesforce org.- Useful for:
- lots of setup changes that takes a long time
- script deployments to multiple environments
- parameters to be used for repetitive deployments, making it suitable for multi-stage release processes
- schedule batch deployments
- move metadata between unrelated orgs (production -> production for example)
- 'build.xml' instructs ANT where and how to deploy and retrieve API calls.
- Components to be moved are described in 'package.xml' file.
- 'desctrutiveChanges.xml' is included to list metadata components when we need to delete certain metadata components in an org.
- Your credentials such as username and password are stored in 'build.properties' on local file system.
- Sample
ANT
commands:deployCode
,deployZip
,retrievePkg
and etc. - Check out link here for more information on deploying with
ANT
: https://focusonforce.com/configuration/deploying-with-ant/
Force.com CLI
Force.com CLI
is the command line interface forForce.com
APIs.- Metadata can be exported and imported.
- It allows deployments using scripted commands and automated tasks.
- Difference between
Force.com Migration Tool
andForce.com CLI
is thatForce.com CLI
does not store username and password on local file system, user needs to login via command line.
Workbench
Workbench
is a lightweight online tool for deploying or retrieving metadata components in production/sandbox environment.- NOTE:
workbench
is not an official salesforce.com product! - URL: https://workbench.developerforce.com
- Things can be done in workbench:
- View object information, metadata types and components.
- Perform SOQL/SOSL query
- CRUD action interface
- Deploy and retrieve metadata components
- Execute REST API via REST Explorer
- Execute Apex Code
- and etc.
Unmanaged Package
Package
is a bundle of components that make up an App or piece of functionality.Unmanaged Package
can be used to distribute open source projects or application templates.- NOTE: do not use unmanaged package to migrate metadata between related orgs such as between sandbox and production.
- Unmanaged package components can be edited once they are installed in an org.
- In contrary,
Managed Package
is protected, upgradeable and typically sold onAppExchange
.
Well, that's all about it! I hope you guys enjoy reading it!
Post was published on , last updated on .
Like the content? Support the author by paypal.me!