7.4 KiB
| title |
|---|
| Migrate DocuSign templates from Sandbox to Production (Salesforce) |
Migrate DocuSign templates from Sandbox to Production
Purpose
- Step-by-step guide to: export templates from DocuSign Demo/Sandbox, import into DocuSign Production, and update (or duplicate) the corresponding Salesforce
dfsle__EnvelopeConfiguration__crecords. - Includes instructions to create the
Short_Name__ccustom field used by our Apex and Flows.
Prerequisites
- DocuSign admin access (Demo + Production) to export/import templates.
- Salesforce admin access to create fields and run Data Loader / sfdx commands.
dfsle(DocuSign for Salesforce) managed package installed in Production.- Optional:
sfdxCLI or Data Loader for bulk changes.
High-level steps
- Export current
dfsle__EnvelopeConfiguration__crecords from Salesforce (backup). - Export templates from DocuSign Demo/Sandbox and import into DocuSign Production.
- Record the new DocuSign template IDs (GUIDs).
- Create the
Short_Name__ccustom field ondfsle__EnvelopeConfiguration__c(if not present). - Prepare CSV mapping old→new template IDs.
- Update existing
dfsle__EnvelopeConfiguration__crecords (or insert duplicates) with new IDs. - Validate by sending test envelopes through the Flow/Apex.
Detailed steps
- Export existing Salesforce configs (backup)
- Recommended fields to export:
Id, Name, dfsle__DocuSignId__c, Short_Name__c, dfsle__EmailMessage__c
- sfdx (CSV output):
sfdx force:data:soql:query -u ORG_ALIAS -q "SELECT Id, Name, dfsle__DocuSignId__c, Short_Name__c, dfsle__EmailMessage__c FROM dfsle__EnvelopeConfiguration__c" --resultformat csv > dfsle_configs_backup.csv
- Or use Workbench / Data Loader to export the same fields.
Keep this CSV safe — it is your rollback and audit record.
- Export templates from DocuSign Demo/Sandbox
-
Use DocuSign Admin UI or API to export templates. Options:
- UI: Admin → Templates (select template) → export / download (if available).
- API: Use eSignature REST API
GET /v2.1/accounts/{accountId}/templates/{templateId}to retrieve template definition; thenPOST /v2.1/accounts/{accountId}/templatesto create in production.
-
After import, capture the new template GUIDs. You can find a template's ID in its template URL or via the API.
- Build mapping of old → new template IDs
- Minimal mapping CSV for updating existing records (update by
Id):
Id,dfsle__DocuSignId__c
00Nxxxxxxxxxxxx,AAAAAAAA-BBBB-CCCC-DDDD-111111111111
00Nyyyyyyyyyyyy,22222222-3333-4444-5555-666666666666
- Minimal CSV for inserting duplicates (keep old records intact):
Name,Short_Name__c,dfsle__DocuSignId__c,dfsle__EmailMessage__c
Invoice Template - EN,INV_EN,AAAAAAAA-BBBB-CCCC-DDDD-111111111111,Please sign the attached invoice
Invoice Template - FR,INV_FR,22222222-3333-4444-5555-666666666666,Veuillez signer la facture
- Create the
Short_Name__cfield ondfsle__EnvelopeConfiguration__c
Why: Our Apex and Flow use Short_Name__c as a compact identifier. If it does not exist in Production, create it before updating/inserting records.
UI (recommended)
- In Salesforce Setup go to Object Manager.
- Search for Envelope Configuration (DocuSign) or type
dfsle__EnvelopeConfiguration__cinto the quick find. - Open Fields & Relationships → New.
- Select Text as the field type.
- Field Label:
Short Name→ Field Name (API):Short_Name→ Length:50(adjust as needed) → Next. - Set Field-Level Security (make visible to integration/admin profiles) → Next.
- Add to Page Layouts if desired → Save.
Notes about managed-package objects
dfsle__EnvelopeConfiguration__cis a managed-package object. You can add subscriber-org custom fields to package objects; the API name will beShort_Name__c(no package namespace for the custom field).- If you cannot create the field via the UI or need to automate it, deploy the field metadata with the Metadata API (MDAPI).
MDAPI example (place under objects/dfsle__EnvelopeConfiguration__c/fields/Short_Name__c.field-meta.xml):
<?xml version="1.0" encoding="UTF-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>Short_Name__c</fullName>
<label>Short Name</label>
<type>Text</type>
<length>50</length>
<inlineHelpText>Short identifier for templates used by Apex/Flows</inlineHelpText>
</CustomField>
Include the field in your package.xml and deploy with sfdx force:mdapi:deploy or your CI.
- Apply the mapping to Salesforce
- Update existing records (in-place update keeps references in other automation intact):
# update by Id
sfdx force:data:bulk:upsert -s dfsle__EnvelopeConfiguration__c -f updates.csv -i Id -u ORG_ALIAS -w 10
- Insert duplicates (if you prefer to preserve old configs):
sfdx force:data:bulk:insert -s dfsle__EnvelopeConfiguration__c -f inserts.csv -u ORG_ALIAS -w 10
- Data Loader: use the GUI to map CSV columns to fields and run Update or Insert jobs.
- Validate & test
- Quick queries:
# list configs with short names
sfdx force:data:soql:query -u ORG_ALIAS -q "SELECT Id, Name, Short_Name__c, dfsle__DocuSignId__c FROM dfsle__EnvelopeConfiguration__c WHERE Short_Name__c != NULL" --resultformat csv
- Send test envelopes:
- Run the Flow that uses the templates from the UI or use the invocable Apex from Developer Console / Execute Anonymous.
- Watch logs / debug to verify the correct
dfsle__DocuSignId__cis used and envelopes are sent successfully.
Example Apex (execute as anonymous) — adapt to your codebase if method names differ:
// Construct an invocable-style request object to test a single template
// Replace types/names with your project types if they differ
compositeEnvelope.DocusignEnvelopeRequest r = new compositeEnvelope.DocusignEnvelopeRequest();
r.templateIds = new List<String>{'NEW-TEMPLATE-GUID'};
r.recordId = '001xxxxxxxxxxxx';
System.debug(JSON.serializePretty(r));
// Call the invocable method or trigger the Flow to verify end-to-end behavior
- Rollback / audit
- Keep the original export CSV as your rollback artifact.
- If something goes wrong, re-run Data Loader using the backup CSV to restore previous
dfsle__DocuSignId__cvalues.
Troubleshooting & tips
- If an insert/update fails, check field-level security and that your user has API access for the managed-package object.
- Some fields on managed-package objects may be controlled by the package; if metadata deploy fails, create the
Short_Name__cfield via the UI. - If your Flow or other automation reference specific Config record Ids, prefer updating in-place rather than inserting duplicates.
Appendix
- SOQL to select configs with non-blank
Short_Name__c:
SELECT Id, Name, Short_Name__c FROM dfsle__EnvelopeConfiguration__c WHERE Short_Name__c != NULL
- Example update CSV (updates.csv):
Id,dfsle__DocuSignId__c
00Nxxxxxxxxxxxx,AAAAAAAA-BBBB-CCCC-DDDD-111111111111
00Nyyyyyyyyyyyy,22222222-3333-4444-5555-666666666666
- Example insert CSV (inserts.csv):
Name,Short_Name__c,dfsle__DocuSignId__c
Invoice Template - EN,INV_EN,AAAAAAAA-BBBB-CCCC-DDDD-111111111111
If you want, I can:
- Export the current
dfsle__EnvelopeConfiguration__crecords from an org (provideORG_ALIAS) and create the mapping CSV template for you. - Create the MDAPI metadata XML for
Short_Name__cunderdeploy/mdapi/objects/dfsle__EnvelopeConfiguration__c/fields/and add it todeploy/mdapi/package.xmlfor deployment.
Last updated: 2026-04-01