Sub topic 2
Finding and Deploying Dependent Components
Assume you know Salesforce metadata types and can access a sandbox and its related production org. A dependency is a component that another component needs to work. For example, an Apex class may reference a custom object, fields, or a custom setting.
Finding and adding dependencies
Start with the main component, then inspect what it references. In an outbound change set, select Add in the Components section. Choose the component type and add the component. Salesforce can show related dependencies through View/Add Dependencies, but you must review the list. Some references, such as permissions, field-level security, or components used indirectly by a Flow, may need manual inspection.
Add every required component to the same change set. A manifest illustrates the idea:
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>Invoice__c</members>
<name>CustomObject</name>
</types>
<types>
<members>InvoiceService</members>
<members>InvoiceServiceTest</members>
<name>ApexClass</name>
</types>
<version>61.0</version>
</Package>| Main component | Possible dependency |
|---|---|
| Apex class | Custom object, field, or test class |
| Flow | Fields, record types, and referenced subflows |
| Lightning page | Custom object, component, or permission |
Uploading the change set
After adding components, click Upload and choose the authorized target org. Salesforce packages the selected metadata and sends it to that org. Uploading does not deploy anything. It creates an inbound change set that an administrator must review and deploy in the target org.
Reviewing the inbound change set
In the target org, open Setup > Inbound Change Sets. Open the uploaded change set and inspect:
- Components and their metadata types
- Warnings or missing dependencies
- The source org and upload time
- The available Validate and Deploy actions
If a dependency is missing, cancel the process, add it to the outbound change set, and upload again.
Validating before deployment
Validation checks whether the target org can deploy the change set without committing its changes. Select Validate, choose the appropriate Apex test level, and review the results. Use specified tests when you need focused coverage, or local and all-tests options when the target org requires broader verification.
Exercise
An Apex class deploys without its referenced custom object. What should you do?
Show answer
Add the custom object and any required fields to the outbound change set, upload it again, then validate the new inbound change set.