[英]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.