我正在尝试从上传到我帐户的模板创建信封。 使用以下代码执行此操作:
public static void main(String[] args) throws ApiException {
// Enter your DocuSign credentials
String UserName = "my-user-name";
String Password = "my-password";
String IntegratorKey = "my-integrator-key";
// for production environment update to "www.docusign.net/restapi"
String BaseUrl = "https://demo.docusign.net/restapi";
// initialize the api client for the desired environment
ApiClient apiClient = new ApiClient();
apiClient.setBasePath(BaseUrl);
// create JSON formatted auth header
String creds = "{\"Username\":\"" + UserName + "\",\"Password\":\"" + Password + "\",\"IntegratorKey\":\"" + IntegratorKey + "\"}";
apiClient.addDefaultHeader("X-DocuSign-Authentication", creds);
// assign api client to the Configuration object
Configuration.setDefaultApiClient(apiClient);
//////////////////////////////// LOGIN START
// login call available off the AuthenticationApi
AuthenticationApi authApi = new AuthenticationApi();
// login has some optional parameters we can set
AuthenticationApi.LoginOptions loginOps = authApi.new LoginOptions();
loginOps.setApiPassword("true");
loginOps.setIncludeAccountIdGuid("true");
LoginInformation loginInfo = authApi.login(loginOps);
// note that a given user may be a member of multiple accounts
List<LoginAccount> loginAccounts = loginInfo.getLoginAccounts();
System.out.println("LoginInformation: " + loginAccounts);
// use the |accountId| we retrieved through the Login API to create the Envelope
String accountId = loginAccounts.get(0).getAccountId();
/////////////////////////////////////// LOGIN END
////////////////////////////////////// CREATE ENVELOPE START
// create a new envelope object that we will manage the signature request through
EnvelopeDefinition envDef = new EnvelopeDefinition();
envDef.setEmailSubject("Hey! Sign the following document");
// assign template information including ID and role(s)
envDef.setTemplateId("ebbe20e3-1c2e-4696-a0c4-41269bf54aeb");
// create a template role with a valid templateId and roleName and assign signer info
TemplateRole tRole = new TemplateRole();
tRole.setRoleName("Client");
String name = "Jake";
String email = "someEmail@goes.here";
tRole.setName(name);
tRole.setEmail(email);
tRole.setClientUserId("someClientUuid");
// create a list of template roles and add our newly created role
List<TemplateRole> templateRolesList = new ArrayList<>();
templateRolesList.add(tRole);
Tabs tabs = new Tabs();
Text clientIdField = new Text();
clientIdField.setTabLabel("CustomerId");
clientIdField.setValue("I changed text from API! It works!");
List<Text> textList = new ArrayList<>();
textList.add(clientIdField);
tabs.setTextTabs(textList);
tRole.setTabs(tabs);
// assign template role(s) to the envelope
envDef.setTemplateRoles(templateRolesList);
// send the envelope by setting |status| to "sent". To save as a draft set to "created"
envDef.setStatus("sent");
// use the |accountId| we retrieved through the Login API to create the Envelope
// instantiate a new EnvelopesApi object
EnvelopesApi envelopesApi = new EnvelopesApi();
// call the createEnvelope() API
EnvelopeSummary envelopeSummary = envelopesApi.createEnvelope(accountId, envDef);
System.out.println("EnvelopeSummary: " + envelopeSummary);
///////////////////////////////////// CREATE ENVELOPE END
String envelopeId = envelopeSummary.getEnvelopeId();
//////////////////////////////////////// CREATE RECIPIENT VIEW
// use the |accountId| we retrieved through the Login API
// instantiate a new EnvelopesApi object
// set the url where you want the recipient to go once they are done signing
RecipientViewRequest returnUrl = new RecipientViewRequest();
returnUrl.setReturnUrl("https://www.docusign.com/devcenter");
returnUrl.setAuthenticationMethod("email");
// recipient information must match embedded recipient info we provided in step #2
returnUrl.setEmail(email);
returnUrl.setUserName(name);
returnUrl.setClientUserId("someClientUuid");
// call the CreateRecipientView API then navigate to the URL to start the signing session
ViewUrl recipientView = envelopesApi.createRecipientView(accountId, envelopeId, returnUrl);
System.out.println("ViewUrl: " + recipientView);
//////////////////////////////////////// CREATE RECIPIENT VIEW
}
我注意到奇怪的事情 - 当我向TemplateRole提供clientUserId字段时,在从模板创建信封时 - 电子邮件通知签名文档不会发送给用户。但是当我删除此字段时 - 电子邮件已成功发送。 问题是我需要在TemplateRole中使用clientUserId才能正确生成ViewUrl以在我的应用程序中使用。
这是一个错误还是一个功能,通知不会与TemplateRole中提供的clientUserId一起发送?在官方网站上没有找到任何关于此的文档。
答案 0 :(得分:0)
指定clientUserId
后,收件人将被视为documentation。默认情况下,只有远程收件人才会收到电子邮件通知。
如果您希望嵌入式收件人接收电子邮件通知,请设置embeddedRecipientStartURL
属性。
tRole.setEmbeddedRecipientStartURL("SIGN_AT_DOCUSIGN")
有关详细信息,请参阅此embedded recipient
官方answer