feat: use Short_Name__c for Document Name when available
Priority: Short_Name__c > stripped Name > template ID Requires adding Short_Name__c (Text 80) custom field to dfsle__EnvelopeConfiguration__c. Falls back to language-stripped Name if Short_Name__c is blank or not populated.
This commit is contained in:
parent
fed796e6cc
commit
5ae3da3c1e
|
|
@ -49,21 +49,31 @@ global with sharing class DocusignCompositeEnvelopeBuilder {
|
|||
sortedTemplateIds.sort();
|
||||
|
||||
// Query template names for document labels (shows in Docusign Status)
|
||||
// Uses Short_Name__c if populated, otherwise falls back to Name (with language suffix stripped)
|
||||
Map<String, String> templateNames = new Map<String, String>();
|
||||
Map<String, String> templateShortNames = new Map<String, String>();
|
||||
for (dfsle__EnvelopeConfiguration__c config : [
|
||||
SELECT dfsle__DocuSignId__c, Name
|
||||
SELECT dfsle__DocuSignId__c, Name, Short_Name__c
|
||||
FROM dfsle__EnvelopeConfiguration__c
|
||||
WHERE dfsle__DocuSignId__c IN :sortedTemplateIds
|
||||
]) {
|
||||
templateNames.put(config.dfsle__DocuSignId__c, config.Name);
|
||||
if (String.isNotBlank(config.Short_Name__c)) {
|
||||
templateShortNames.put(config.dfsle__DocuSignId__c, config.Short_Name__c);
|
||||
}
|
||||
}
|
||||
|
||||
List<dfsle.Document> documents = new List<dfsle.Document>();
|
||||
List<String> docNames = new List<String>();
|
||||
for (String templateId : sortedTemplateIds) {
|
||||
String label = templateNames.containsKey(templateId)
|
||||
? stripLanguageSuffix(templateNames.get(templateId))
|
||||
: templateId;
|
||||
String label;
|
||||
if (templateShortNames.containsKey(templateId)) {
|
||||
label = templateShortNames.get(templateId);
|
||||
} else if (templateNames.containsKey(templateId)) {
|
||||
label = stripLanguageSuffix(templateNames.get(templateId));
|
||||
} else {
|
||||
label = templateId;
|
||||
}
|
||||
documents.add(
|
||||
dfsle.Document.fromTemplate(
|
||||
dfsle.UUID.parse(templateId),
|
||||
|
|
|
|||
Loading…
Reference in New Issue