# Deployment & Migration

### Symptom

Component works in builder or sandbox but fails when deployed to production or used by end-users.

***

### Common Causes and Solutions

#### 1. User Permissions Different

**Check:** End users may lack permissions that admins/developers have.

**Solution:**

* Test component as actual end user (not as System Administrator)
* Review object and field-level security
* Update permissions if needed
* Document permission requirements

**Example:**

```
❌ Problem:
- Admin can see confidential_notes__c field
- Support Agent cannot (no field-level security)
- Component breaks for Support Agent

✅ Solution:
- Grant field access to Support Agent profile
- Or remove field from component
- Test as Support Agent before deploying
```

***

#### 2. Record Access Issues

**Check:** Users cannot access records due to sharing rules.

**Solution:**

* Review organization-wide defaults
* Check sharing rules and role hierarchy
* Test with various user roles
* Verify users can see records in standard UI first

**Example:**

```
❌ Problem:
- OWD: Opportunity = Private
- Sales Rep sees "No records found"
- Component queries all opportunities

✅ Solution:
- Create sharing rule for sales team
- Or filter component by OwnerId = Current User
- Test as Sales Rep to confirm access
```

***

#### 3. Environment Differences

**Check:** Sandbox and production have different configurations.

**Solution:**

* Verify custom fields exist in target org
* Check picklist values match
* Review automation differences
* Test with production-like data

**Example:**

```
❌ Problems in Production:
- Missing Product_Image_URL__c field
- Category picklist missing "Software" value
- Different record types than sandbox

✅ Solutions:
- Deploy custom fields first
- Add missing picklist values
- Update component to handle both environments
- Use deployment checklist
```

***

#### 4. API Version Mismatches

**Check:** Production org may be on older Salesforce release.

**Solution:**

* Check component API version
* Verify production is on same or newer release
* Wait for production org update if needed
* Use compatible features for older versions

***

#### 5. Managed Package Version Differences

**Check:** Sandbox and production may have different Dynamic Components package versions installed.

**Solution:**

* Check package version in both orgs (Setup > Installed Packages)
* [Upgrade production](https://docs.avonnicomponents.com/dynamic-components/resources/troubleshooting-and-faq/broken-reference) to match sandbox version
* Or rebuild component using features available in production version
* Note version requirements in deployment documentation

**Example:**

```
❌ Problem:
- Sandbox: Dynamic Components v1.5.0
- Production: Dynamic Components v1.3.0
- Component uses new features from v1.5.0
- Deployment fails or component doesn't work

✅ Solution:
- Upgrade production package to v1.5.0 first
- Then deploy component
```

***

### Deployment Process

For complete deployment instructions, see: [**Deploying Dynamic Components Guide**](https://docs.avonnicomponents.com/dynamic-components/resources/deployment-process)

***

### Pre-Deployment Checklist

* [ ] List all dependencies (fields, objects, components)
* [ ] Verify dependencies exist in target org
* [ ] Test with end-user permissions (not admin)
* [ ] Check sharing rules and security
* [ ] Test with production-like data
* [ ] Document required permissions
