我的模板定义了一个角色。我尝试根据模板发送信封并填写该角色的名称和电子邮件,以便用户不必放置自己的签名块。
问题是它在信封上添加了第二个签名者。然后获得要求他们签名的电子邮件的第二个签名者必须手动放置他们的签名,因为签名块仅为第一个签名者定义。
我从这里开始使用代码:https://www.docusign.com/p/APIGuide/Content/Sending%20Group/CreateEnvelopeFromTemplates.htm
这是我的代码。这是Java代码。
// just get the first template for now
EnvelopeTemplates templates = port.requestTemplates(accountId, false);
String templateId = templates.getEnvelopeTemplateDefinition().get(0).getTemplateID();
EnvelopeTemplate template = port.requestTemplate(templateId, false);
// get the existing recipient from the template
Recipient recipient = template.getEnvelope().getRecipients().getRecipient().get(0);
recipient.setEmail("asdf@example.com");
recipient.setUserName("John Doe");
ArrayOfRecipient1 recipients = new ArrayOfRecipient1();
recipients.getRecipient().add(recipient);
ArrayOfCustomField arrayOfCustomField = new ArrayOfCustomField();
CustomField f = new CustomField();
f.setName("masterRecordId");
f.setValue("1");
f.setShow("false");
arrayOfCustomField.getCustomField().add(f);
// define envelope info
EnvelopeInformation envelopeInformation = new EnvelopeInformation();
envelopeInformation.setSubject("test email subject");
envelopeInformation.setAccountId(accountId);
envelopeInformation.setEmailBlurb("test email blurb");
envelopeInformation.setCustomFields(arrayOfCustomField);
// define template
ArrayOfTemplateReference arrayOfTemplateReference = new ArrayOfTemplateReference();
TemplateReference templateReference = new TemplateReference();
templateReference.setTemplate(template.getEnvelopeTemplateDefinition().getTemplateID());
templateReference.setTemplateLocation(TemplateLocationCode.SERVER);
arrayOfTemplateReference.getTemplateReference().add(templateReference);
EnvelopeStatus status = port.createEnvelopeFromTemplates(arrayOfTemplateReference, recipients, envelopeInformation, false);
答案 0 :(得分:0)
如果您已经在模板上定义了收件人角色,则需要在代码中引用该角色,而不是在此处创建新角色。我认为两个收件人来自模板+ 1来自代码。
设置recipient.roleName以匹配您在模板上为其指定的名称。
答案 1 :(得分:0)
缺少的部分是你必须添加TemplateReferenceRoleAssignment。这是代码的一部分:
TemplateReferenceRoleAssignment trra = new TemplateReferenceRoleAssignment();
trra.setRoleName("Stake holder");
trra.setRecipientID(recipientId);
templateReference.getRoleAssignments().getRoleAssignment().add(trra);
以下是完整的工作代码:
// create envelope from template
EnvelopeTemplates templates = port.requestTemplates(accountId, false);
String templateId = templates.getEnvelopeTemplateDefinition().get(0).getTemplateID();
EnvelopeTemplate template = port.requestTemplate(templateId, false);
ArrayOfCustomField arrayOfCustomField = new ArrayOfCustomField();
CustomField f = new CustomField();
f.setName("masterRecordId");
f.setValue("1");
f.setShow("false");
arrayOfCustomField.getCustomField().add(f);
// define envelope info
EnvelopeInformation envelopeInformation = new EnvelopeInformation();
envelopeInformation.setSubject("test email subject");
envelopeInformation.setAccountId(accountId);
envelopeInformation.setEmailBlurb("test email blurb");
envelopeInformation.setCustomFields(arrayOfCustomField);
// define template
TemplateReference templateReference = new TemplateReference();
templateReference.setRoleAssignments(new ArrayOfTemplateReferenceRoleAssignment());
templateReference.setTemplate(template.getEnvelopeTemplateDefinition().getTemplateID());
templateReference.setTemplateLocation(TemplateLocationCode.SERVER);
BigInteger recipientId = BigInteger.valueOf(1);
// define the recipient info
Recipient recipient = new Recipient();
recipient.setID(recipientId);
recipient.setEmail("jane@example.org");
recipient.setUserName("Jane Doe");
recipient.setType(RecipientTypeCode.SIGNER);
ArrayOfRecipient1 recipients = new ArrayOfRecipient1();
recipients.getRecipient().add(recipient);
// this links the recipient above with the role in the template
TemplateReferenceRoleAssignment trra = new TemplateReferenceRoleAssignment();
trra.setRoleName("Stake holder");
trra.setRecipientID(recipientId);
templateReference.getRoleAssignments().getRoleAssignment().add(trra);
// make the API call to send off the envelope
ArrayOfTemplateReference arrayOfTemplateReference = new ArrayOfTemplateReference();
arrayOfTemplateReference.getTemplateReference().add(templateReference);
EnvelopeStatus status = port.createEnvelopeFromTemplates(arrayOfTemplateReference, recipients, envelopeInformation, true);