Docusign 模板不与 APEX 代码合并
Docusign Template is no merging with APEX code
我将机会 ID 发送到 mySourceId 到例程中,然后 运行 通过标准的 Docusign APEX API 例程。我们有一个按钮可以使用标准的 Docusign 例程完成此合并,但我们正试图绕过用户不得不忍受的所有额外按钮点击。
我有一个在 Docusign 上创建并可用的模板,文档上带有 Salesforce 相关的自定义字段标签。文档中是否有我遗漏的内容?
//create the emptyenvelope connecting it to the SF object
myEnvelope = dfsle.EnvelopeService.getEmptyEnvelope(new dfsle.Entity(**mySourceId**));
//use the Recipient.fromSource method to create the Recipient
dfsle.Recipient myRecipient = dfsle.Recipient.fromSource(sender.name, // Recipient name
sender.eAddress, // Recipient email
null, //Optional phone number
sender.role, //Role Name. Specify the exact role name from template
new dfsle.Entity(**mySourceId**)); //source object for the Recipient
//add email detail for the envelope
myEnvelope = myEnvelope.withEmail(settingsDocusignTemplate.get(sourceName).email_subject__c, settingsDocusignTemplate.get(sourceName).email_body__c);
//Could provide automatic notifications as well based off of criteria
final boolean dfsle_reminder = settingsDocusignTemplate.get(sourceName).reminder__c;
final integer dfsle_remindAfterDays = Integer.valueOf(settingsDocusignTemplate.get(sourceName).remindAfterDays__c); //wait before sending reminder
//add Recipient to the Envelope
myEnvelope = myEnvelope.withRecipients(new List<dfsle.Recipient> { myRecipient });
//create a new document for the Envelope
dfsle.Document myDocument = dfsle.Document.fromTemplate((dfsle.UUID)templateInfo.get('UUID'), // templateId in dfsle.UUID format
(String)templateInfo.get('name')); // name of the template
//add document to the Envelope
myEnvelope = myEnvelope.withDocuments(new List<dfsle.Document> { myDocument });
try {
System.debug('\tSending Envelope');
dfsle.EnvelopeService.sendEnvelope(myEnvelope, // The envelope to send
true); // Send now?
} catch (dfsle.DocuSignException docusignExcpt) {
ErrorLogUtil.createErrorLogData(docusignExcpt,CLASS_NAME,METHOD_NAME,null,null);
} catch (Exception excp) {
ErrorLogUtil.createErrorLogData(excp,CLASS_NAME,METHOD_NAME,null,null);
}
尝试在“为信封创建新文档”之后将其添加到您的代码中
String opptyStr = (String) myOpportunity.Id + '~Opportunity';
dfsle.CustomField myField = new dfsle.CustomField ('text', 'DSFSSourceObjectId', opptyStr, null, false, false);
//add document to the Envelope
myEnvelope = myEnvelope.withDocuments(new List<dfsle.Document> { myDocument })
.withCustomFields(new List<dfsle.CustomField> {myField});
技术上不支持合并字段,但我们可以通过使用带有此代码的自定义字段来解决此问题。
withCustomFields(新列表 {myField})
如何将多个字段添加到列表 new List {myField}?
最后变成了这个样子;
templateInfo.put('Source_Reference',(String) mySourceId + '~Opportunity');
dfsle.CustomField sourceField = new dfsle.CustomField ('text', 'DSFSSourceObjectId', (String)templateInfo.get('Source_Reference'), null, false, false);
//add document to the Envelope
myEnvelope = myEnvelope.withDocuments(new List<dfsle.Document> { myDocument });
//populate the custom fields on the Envelope
myEnvelope = myEnvelope.withCustomFields(new List<dfsle.CustomField> {sourceField});
我将机会 ID 发送到 mySourceId 到例程中,然后 运行 通过标准的 Docusign APEX API 例程。我们有一个按钮可以使用标准的 Docusign 例程完成此合并,但我们正试图绕过用户不得不忍受的所有额外按钮点击。
我有一个在 Docusign 上创建并可用的模板,文档上带有 Salesforce 相关的自定义字段标签。文档中是否有我遗漏的内容?
//create the emptyenvelope connecting it to the SF object
myEnvelope = dfsle.EnvelopeService.getEmptyEnvelope(new dfsle.Entity(**mySourceId**));
//use the Recipient.fromSource method to create the Recipient
dfsle.Recipient myRecipient = dfsle.Recipient.fromSource(sender.name, // Recipient name
sender.eAddress, // Recipient email
null, //Optional phone number
sender.role, //Role Name. Specify the exact role name from template
new dfsle.Entity(**mySourceId**)); //source object for the Recipient
//add email detail for the envelope
myEnvelope = myEnvelope.withEmail(settingsDocusignTemplate.get(sourceName).email_subject__c, settingsDocusignTemplate.get(sourceName).email_body__c);
//Could provide automatic notifications as well based off of criteria
final boolean dfsle_reminder = settingsDocusignTemplate.get(sourceName).reminder__c;
final integer dfsle_remindAfterDays = Integer.valueOf(settingsDocusignTemplate.get(sourceName).remindAfterDays__c); //wait before sending reminder
//add Recipient to the Envelope
myEnvelope = myEnvelope.withRecipients(new List<dfsle.Recipient> { myRecipient });
//create a new document for the Envelope
dfsle.Document myDocument = dfsle.Document.fromTemplate((dfsle.UUID)templateInfo.get('UUID'), // templateId in dfsle.UUID format
(String)templateInfo.get('name')); // name of the template
//add document to the Envelope
myEnvelope = myEnvelope.withDocuments(new List<dfsle.Document> { myDocument });
try {
System.debug('\tSending Envelope');
dfsle.EnvelopeService.sendEnvelope(myEnvelope, // The envelope to send
true); // Send now?
} catch (dfsle.DocuSignException docusignExcpt) {
ErrorLogUtil.createErrorLogData(docusignExcpt,CLASS_NAME,METHOD_NAME,null,null);
} catch (Exception excp) {
ErrorLogUtil.createErrorLogData(excp,CLASS_NAME,METHOD_NAME,null,null);
}
尝试在“为信封创建新文档”之后将其添加到您的代码中
String opptyStr = (String) myOpportunity.Id + '~Opportunity';
dfsle.CustomField myField = new dfsle.CustomField ('text', 'DSFSSourceObjectId', opptyStr, null, false, false);
//add document to the Envelope
myEnvelope = myEnvelope.withDocuments(new List<dfsle.Document> { myDocument })
.withCustomFields(new List<dfsle.CustomField> {myField});
技术上不支持合并字段,但我们可以通过使用带有此代码的自定义字段来解决此问题。
withCustomFields(新列表
如何将多个字段添加到列表 new List
最后变成了这个样子;
templateInfo.put('Source_Reference',(String) mySourceId + '~Opportunity');
dfsle.CustomField sourceField = new dfsle.CustomField ('text', 'DSFSSourceObjectId', (String)templateInfo.get('Source_Reference'), null, false, false);
//add document to the Envelope
myEnvelope = myEnvelope.withDocuments(new List<dfsle.Document> { myDocument });
//populate the custom fields on the Envelope
myEnvelope = myEnvelope.withCustomFields(new List<dfsle.CustomField> {sourceField});