salesforce-composite-envelo.../composite-envelope-builder/docs/migrate-docusign-templates-...

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__c records.
  • Includes instructions to create the Short_Name__c custom 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: sfdx CLI or Data Loader for bulk changes.

High-level steps

  1. Export current dfsle__EnvelopeConfiguration__c records from Salesforce (backup).
  2. Export templates from DocuSign Demo/Sandbox and import into DocuSign Production.
  3. Record the new DocuSign template IDs (GUIDs).
  4. Create the Short_Name__c custom field on dfsle__EnvelopeConfiguration__c (if not present).
  5. Prepare CSV mapping old→new template IDs.
  6. Update existing dfsle__EnvelopeConfiguration__c records (or insert duplicates) with new IDs.
  7. Validate by sending test envelopes through the Flow/Apex.

Detailed steps

  1. 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.

  1. 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; then POST /v2.1/accounts/{accountId}/templates to 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.

  1. 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
  1. Create the Short_Name__c field on dfsle__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)

  1. In Salesforce Setup go to Object Manager.
  2. Search for Envelope Configuration (DocuSign) or type dfsle__EnvelopeConfiguration__c into the quick find.
  3. Open Fields & RelationshipsNew.
  4. Select Text as the field type.
  5. Field Label: Short Name → Field Name (API): Short_Name → Length: 50 (adjust as needed) → Next.
  6. Set Field-Level Security (make visible to integration/admin profiles) → Next.
  7. Add to Page Layouts if desired → Save.

Notes about managed-package objects

  • dfsle__EnvelopeConfiguration__c is a managed-package object. You can add subscriber-org custom fields to package objects; the API name will be Short_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.

  1. 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.
  1. 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__c is 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
  1. 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__c values.

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__c field 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__c records from an org (provide ORG_ALIAS) and create the mapping CSV template for you.
  • Create the MDAPI metadata XML for Short_Name__c under deploy/mdapi/objects/dfsle__EnvelopeConfiguration__c/fields/ and add it to deploy/mdapi/package.xml for deployment.

Last updated: 2026-04-01