使用Docusign发送Salesforce附件

使用Docusign发送Salesforce附件,salesforce,docusignapi,Salesforce,Docusignapi,我正在尝试使用Salesforce apex代码中的DocuSign API发送一个包含文档的信封 当使用DocuSign沙箱中设置的templateid时,它可以工作,但我想使用与记录相关的Salesforce附件,我遇到了一个异常 dfsle.DocuSignException: Unable to read content for documents: Disti1234B.pdf (001f400000za2c9AAA). 知道我为什么会得到它吗? 请注意,我尝试在SF中同时使用附件和

我正在尝试使用Salesforce apex代码中的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 documentation,它仅处理salesforce中的文档文件,而不处理salesforce附件。根据异常消息,无法读取附件文档。您是否检查过该文档或尝试过其他附件?该文档似乎没有问题。当我使用按钮打开窗口,选择文档和收件人并发送它时,它工作正常当使用代码时,其他文档也会出现这种情况