[英]Send Salesforce Attachment with Docusign
我正在尝试在 Salesforce(顶点代码)中使用 DocuSign API 来发送包含文档的信封。
使用在我的 DocuSign 沙箱中设置的 templateid 时它正在工作,但我想使用与记录相关的 Salesforce 附件,但我收到了一个例外
dfsle.DocuSignException: Unable to read content for documents: Disti1234B.pdf (001f400000za2c9AAA).
知道为什么我会得到它吗? 请注意,我尝试在 SF 中同时使用附件和文件,但在两者中都出现了相同的错误。
Trace:
FATAL_ERROR Class.dfsle.EnvelopeAPI: line 1027, column 1
Class.dfsle.EnvelopeAPI.APIEnvelope.<init>: line 1065, column 1
Class.dfsle.EnvelopeAPI.createEnvelope: line 1155, column 1
Class.dfsle.EnvelopeAPI.createEnvelope: line 1144, column 1
Class.dfsle.EnvelopeService.sendEnvelope: line 641, column 1
Class.dfsle.EnvelopeService.sendEnvelope: line 607, column 1
代码脚本:
Id accountId = '001f400000za2c9'; // The ID of the initiating Salesforce object.
// Create an empty envelope.
dfsle.Envelope myEnvelope = dfsle.EnvelopeService.getEmptyEnvelope(new dfsle.Entity(accountId));
//we will use a Salesforce contact record as a Recipient here
Contact myContact = [SELECT Id, Name, Email FROM Contact where Id = '003f400001Gk49f'];
//use the Recipient.fromSource method to create the Recipient
dfsle.Recipient myRecipient = dfsle.Recipient.fromSource(
myContact.Name, // Recipient name
myContact.Email, // Recipient email
null, //Optional phone number
'Signer 1', //Role Name. Specify the exact role name from template
new dfsle.Entity(myContact.Id)); //source object for the Recipient
//add Recipient to the Envelope
myEnvelope = myEnvelope.withRecipients(new List<dfsle.Recipient> { myRecipient });
/*WITH TEMPLATE ID IT IS WORKING FINE
//myTemplateId contains the DocuSign Id of the DocuSign Template
dfsle.UUID myTemplateId = dfsle.UUID.parse('f4252788-0799-4786-bac4-7c6a3f1d37a8');
//create a new document for the Envelope
dfsle.Document myDocument = dfsle.Document.fromTemplate(
myTemplateId, // templateId in dfsle.UUID format
'myTemplate'); // name of the template
*/
Attachment att = [SELECT Id, Name, Body, ContentType,LastModifiedDate,BodyLength FROM Attachment WHERE Id = '00Pf400000KPKBh'];
dfsle.Document myDocument = new dfsle.Document(att.Id, 'File', 1, att.Name, 'pdf', att.BodyLength, att.LastModifiedDate, accountId);
//add document to the Envelope
myEnvelope = myEnvelope.withDocuments(new List<dfsle.Document> { myDocument });
myEnvelope = dfsle.EnvelopeService.sendEnvelope(myEnvelope, true);
仍然不确定为什么会发生这种情况,但我能够通过使用以下方法使其工作:
list<dfsle.Document> l_doc = dfsle.DocumentService.getDocuments(ContentVersion.getSObjectType(), new set<Id>{'068f400000EFNuaAAH'});
请注意,根据 docusign 文档,它仅适用于文档(Salesforce 中的文件),不适用于 Salesforce 附件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.