feat: envelope uses combined template names for subject and concatenated dfsle_EmailMessage__c for body

- Email subject is now combined document names (Short_Name__c if available)
- Email body is concatenated dfsle_EmailMessage__c from each selected template
- No longer uses template-level email subject for envelope
- Keeps status/document name logic unchanged
This commit is contained in:
Paul Huliganga 2026-02-25 23:55:30 -05:00
parent 5ae3da3c1e
commit 03a8f48e8d
1 changed files with 20 additions and 3 deletions

View File

@ -103,10 +103,27 @@ global with sharing class DocusignCompositeEnvelopeBuilder {
List<dfsle.Recipient> recipients = resolveRecipients(req.recordId); List<dfsle.Recipient> recipients = resolveRecipients(req.recordId);
myEnvelope = myEnvelope.withRecipients(recipients); myEnvelope = myEnvelope.withRecipients(recipients);
// Set email subject if provided // Set envelope subject to combined template names and body to concatenated template email messages
if (String.isNotBlank(req.emailSubject)) { // Query for EmailMessage__c
myEnvelope = myEnvelope.withEmail(req.emailSubject, ''); Map<String, String> templateBodies = new Map<String, String>();
for (dfsle__EnvelopeConfiguration__c config : [
SELECT dfsle__DocuSignId__c, dfsle__EmailMessage__c
FROM dfsle__EnvelopeConfiguration__c
WHERE dfsle__DocuSignId__c IN :sortedTemplateIds
]) {
if (String.isNotBlank(config.dfsle__EmailMessage__c)) {
templateBodies.put(config.dfsle__DocuSignId__c, config.dfsle__EmailMessage__c);
}
} }
List<String> bodyParts = new List<String>();
for (String templateId : sortedTemplateIds) {
if (templateBodies.containsKey(templateId)) {
bodyParts.add(templateBodies.get(templateId));
}
}
String envelopeSubject = combinedName;
String envelopeBody = bodyParts.isEmpty() ? '' : String.join(bodyParts, '\n\n');
myEnvelope = myEnvelope.withEmail(envelopeSubject, envelopeBody);
// Send the envelope // Send the envelope
myEnvelope = dfsle.EnvelopeService.sendEnvelope(myEnvelope, true); myEnvelope = dfsle.EnvelopeService.sendEnvelope(myEnvelope, true);