# Deploying Flow and APEX Code to Salesforce Production This guide provides step-by-step instructions for moving your Flow and APEX code from a sandbox to a Salesforce production organization **using Salesforce's built-in tools** (no local source code required). ## Prerequisites - You have access to both the sandbox and production Salesforce orgs. - You have System Administrator permissions in both orgs. - The Flow and APEX code are already deployed and tested in the sandbox. --- ## 1. Use Change Sets to Deploy Metadata ### A. Create an Outbound Change Set in Sandbox 1. **Login to your Sandbox**. 2. Go to **Setup** > **Change Sets** > **Outbound Change Sets**. 3. Click **New** to create a new change set (e.g., "Docusign Composite Envelope Builder"). 4. Add a description for clarity. 5. Click **Save**. ### B. Add Components to the Change Set 1. In the change set, click **Add** under "Change Set Components". 2. **Add the Flow(s):** - Component Type: `Flow Definition` or `Flow`. - Select the active Flow version for the application. For this repository the Flow to include is `Docusign_Envelope_Templates_V4`. 3. **Add APEX Classes:** - Component Type: `Apex Class`. - Include the following Apex classes from the package: - `DocusignCompositeEnvelopeBuilder` - `DocusignEnvelopeRequest` - `DocusignEnvelopeRequestHandler` - `DocusignEnvelopeResult` - Also include associated test classes: - `DocusignCompositeEnvelopeBuilderTest` - `DocusignEnvelopeRequestHandlerTest` 4. **Apex Triggers:** - This package does not include any Apex Triggers. There are no trigger files in `force-app/main/default/triggers` to add to the change set. 5. **Custom Objects / Fields:** - There are no custom objects or custom fields that must be deployed for the current implementation. The repository does contain a `Docusign_Configuration__c` object (with `Account_Id__c` and `Base_URL__c`) in `force-app/main/default/objects`, but it is not referenced by the APEX classes or the Flow (the implementation uses the `dfsle` toolkit and `dfsle__EnvelopeConfiguration__c` templates). You do not need to include `Docusign_Configuration__c` or its fields in the change set unless you intentionally want to preserve that leftover metadata. 6. Click **Add to Change Set** after each selection. ### C. Add Profiles/Permission Sets (Optional) - If your app uses custom permissions, add the relevant profiles or permission sets. ### D. Upload the Change Set to Production 1. In the change set, click **Upload**. 2. Select your production org as the target. 3. Click **Upload**. --- ## 2. Deploy the Change Set in Production ### A. Login to Production 1. **Login to your Production Salesforce org**. 2. Go to **Setup** > **Change Sets** > **Inbound Change Sets**. ### B. Validate and Deploy 1. Find the uploaded change set. 2. Click the change set name to review components. 3. Click **Validate** to run tests and check for errors. 4. If validation passes, click **Deploy**. 5. Monitor deployment status and resolve any errors if needed. --- ## 3. Post-Deployment Steps - **Assign Permission Sets/Profiles** to users as needed. - **Test the Flow and APEX functionality** in production. - **Review Custom Settings/Metadata** for environment-specific values (e.g., API keys, URLs). --- ## Troubleshooting - If deployment fails, review error messages for missing dependencies or test failures. - Ensure all referenced components (objects, fields, flows, classes) are included in the change set. - For large or complex deployments, consider deploying in smaller batches. --- ## References - [Salesforce Change Sets Documentation](https://help.salesforce.com/s/articleView?id=sf.changesets.htm) - [Deploy Flows with Change Sets](https://help.salesforce.com/s/articleView?id=sf.flow_deploy.htm) - [Deploy Apex Code with Change Sets](https://help.salesforce.com/s/articleView?id=sf.code_deploy_changeset.htm) --- **Contact your Salesforce administrator or partner for additional support if needed.**