从模板创建信封时签名选项卡不可见

Signature tab is not visible when envelope is created from template

对于以下要求,我们希望将 DocuSign 用于 SalesForce:
1. 内部用户,点击页面布局上的按钮触发 DocuSign 2. 社区用户,点击 VF 页面上的按钮触发 DocuSign

为此,我连接了 salesforce 和 Docusign 帐户。并完成基本配置,例如在 DocuSign 和 SalesForce 之间连接自定义变量,使用 pdf 和一些选项卡创建模板,例如 SignatureInitial签署日期。假设模板 ID 是 aa3d9632-1595-4fef-87dd-1795334edf9d.

现在,根据上面的第一个要求,我在使用创建的模板 aa3d9632-1595-4fef-87dd-1795334edf9d 的页面布局上创建了一个 JavaScript 按钮。在这里,当内部用户单击按钮时,收件人可以看到所有选项卡(签名初始签名日期) 包含在模板中。

对于第二个要求,我正在使用 SOAP API 来触发 DocuSign。因为我已经有一个模板 aa3d9632-1595-4fef-87dd-1795334edf9d,所以我也想在我的第二个要求中使用它。为此,我正在使用 CreateEnvelopeFromTemplates() 方法,请在下面的代码段中使用:

//Step #1) Buiding Template, Recipient and Envelope information
// 1.1) Put the created template from DocuSign

DocuSignAPI.TemplateReference templetRef = new DocuSignAPI.TemplateReference();
templetRef.Template = aa3d9632-1595-4fef-87dd-1795334edf9d;
templetRef.TemplateLocation = 'Server';

DocuSignAPI.ArrayOfTemplateReference templetRefs = new DocuSignAPI.ArrayOfTemplateReference();
templetRefs.TemplateReference = new DocuSignAPI.TemplateReference[]{templetRef};
system.debug('templetRefs: '+templetRefs);

// 1.2) Create a Recipient
DocuSignAPI.Recipient recipient = new DocuSignAPI.Recipient();
recipient.Email         = docuSign_email;
recipient.UserName      = docuSign_fName+' '+docuSign_lName;
recipient.Type_x        = 'Signer';
recipient.ID            = 1;
recipient.RoutingOrder  = 1; 
recipient.RequireIDLookup = false;

DocuSignAPI.ArrayOfRecipient1 recipients = new DocuSignAPI.ArrayOfRecipient1();
recipients.Recipient = new DocuSignAPI.Recipient[]{recipient};

system.debug('recipients: '+recipients);           


// 1.3) Construct the envelope information
DocuSignAPI.EnvelopeInformation envelopeInfo = new DocuSignAPI.EnvelopeInformation();
envelopeInfo.Subject    = 'Terms of Agreement for your Signature';
envelopeInfo.EmailBlurb = 'We are sending you this request for your electronic signature, please review and electronically sign by following the link above. ';
envelopeInfo.AccountId  = accountId;

//Populate Application as a Custom Field in Envelope
DocuSignAPI.CustomField custFiled = new DocuSignAPI.CustomField();
custFiled.Name      = 'DSFSSourceObjectId';
custFiled.Value     = docuSign_appID;
custFiled.show      = 'False';
custFiled.Required  = 'True';
custFiled.CustomFieldType = 'Text';

DocuSignAPI.ArrayOfCustomField CustFields = new DocuSignAPI.ArrayOfCustomField();
//CustFields.CustomField = new DocuSignAPI.CustomField[]{custFiled,accFiled};
CustFields.CustomField = new DocuSignAPI.CustomField[]{custFiled};

envelopeInfo.CustomFields = CustFields;             

system.debug('envelopeInfo: '+envelopeInfo);

// Step #2) Create a Envelope with informtion created from step #1 and SendEnvelope
System.debug('Calling the API');

//DocuSignAPI.EnvelopeStatus es  = dsApiSend.CreateAndSendEnvelope(envelope);
DocuSignAPI.EnvelopeStatus envelopStatus = dsApiSend.CreateEnvelopeFromTemplates(templetRefs, recipients,envelopeInfo,true);
envelopeId = envelopStatus.EnvelopeID;

在这种情况下,收件人无法看到任何选项卡(签名初始签名日期) 包含在模板中。

奇怪的是,当用户单击页面布局 JavaScript 按钮时,这些选项卡可见,但在 VF 页面按钮单击时不可见。

您必须将您的收件人映射到您的模板角色

这是需要更新的代码片段。

  • 我已设置收件人角色名称recipient.RoleName = 'Signer 1'
  • 创建了 ArrayOfTemplateReferenceRoleAssignment 并添加到 TemplateReference。

查看完整代码here

 // 1.2) Create a Recipient
 DocuSignAPI.Recipient recipient = new DocuSignAPI.Recipient();
 recipient.Email         = docuSign_email;
 recipient.UserName      = docuSign_fName+' '+docuSign_lName;
 recipient.Type_x        = 'Signer';
 recipient.ID            = 1;
 recipient.RoutingOrder  = 1; 
 recipient.RequireIDLookup = false;
 recipient.RoleName = 'Signer 1';

 DocuSignAPI.ArrayOfRecipient1 recipients = new DocuSignAPI.ArrayOfRecipient1();
 recipients.Recipient = new DocuSignAPI.Recipient[]{recipient};


 ArrayOfTemplateReferenceRoleAssignment tras = new ArrayOfTemplateReferenceRoleAssignment();
 TemplateReferenceRoleAssignment assign = new TemplateReferenceRoleAssignment();
 assign.setRoleName(recipient.getRoleName());
 assign.setRecipientID(recipient.getID());
 tras.getRoleAssignment().add(assign);
 templetRef.setRoleAssignments(tras);