Updating textField value when last signer signs the document.
Friday, August 9, 2019 at 06:58amHi,
We need to send a document to one or more signers and then sign as a company (we are the last signer). Also, we need to write some info in the document at that moment. So, I added a textField in the document with no value when uploading / sending the document, and when we are signing the document as the last signer trying to change the value to the textField. It does not work.
The code is something like this:
Uploading / Sending the document
DocumentBuilder documentBuilder = DocumentBuilder.newDocumentWithName(documentPackageName)
.fromFile(file.getAbsolutePath())
.enableExtraction()
.withExtractionType(ExtractionType.TEXT_TAGS);
documentBuilder = documentBuilder.withId("documentId")
.withSignature(SignatureBuilder.signatureFor(senderEmail)
.withId(new SignatureId("companySignature"))
.withPositionAnchor(TextAnchorBuilder.newTextAnchor("SIGNATURE:")
.withSize(150, 40)
.withOffset(0, 10)
.withCharacter(0)
.withOccurence(0))
.withField(FieldBuilder.textField()
.withId(new FieldId("fieldId"))
.withPositionAnchor(TextAnchorBuilder.newTextAnchor("TEXT:")
.withSize(100, 40)
.withOffset(30, 10)
.withCharacter(0)
.withOccurence(0))
)
);
Document document = documentBuilder.build();
eslClient.uploadDocument(document, packageId);
Signing the document
// Change Package Status to DRAFT
DocumentPackage documentPackage = eslClient.getPackage(packageId);
documentPackage.setStatus(PackageStatus.DRAFT);
eslClient.updatePackage(packageId, documentPackage);
// Fill textField
SignatureId signatureId = new SignatureId("companySignature");
FieldId fieldId = new FieldId("fieldId");
Field field = eslClient.getApprovalService().getField(packageId, "documentId", signatureId, fieldId);
field.setValue("START DATE");
eslClient.getApprovalService().updateField(packageId, "documentId", signatureId, field);
// Return Package Status to SENT
documentPackage.setStatus(PackageStatus.SENT);
eslClient.updatePackage(packageId, documentPackage);
// Sign Documents
eslClient.signDocuments(packageId, sender.getEmail());
// Mark Transaction as completed.
PackageService packageService = eslClient.getPackageService();
packageService.markComplete(packageId);
We would appreciate any suggestion.
Thanks
Reply to: Updating textField value when last signer signs the document.
Friday, August 9, 2019 at 09:18amContent-type: application/json Authorization: Basic {your_api_key}Payload:{"value":"START DATE"}There's no corresponding SDK function out of the box, so if you want, I can create some sample code for you. Hope this could help! DuoReply to: Updating textField value when last signer signs the document.
Friday, August 9, 2019 at 09:43amReply to: Updating textField value when last signer signs the document.
Friday, August 9, 2019 at 10:40amprivate void updateFieldValue(String packageId, String documentId, String signatureId, String fieldId,String newValue) { HttpURLConnection sourceConn = null; String url = API_URL.substring(0, API_URL.lastIndexOf("/api"))+"/packages/" + packageId + "/documents/" + documentId+"/approvals/" + signatureId + "/fields/" + fieldId; System.out.println(url); try { URL sourceClient = new URL(url); sourceConn = (HttpURLConnection) sourceClient.openConnection(); sourceConn.setRequestProperty("Content-Type", "application/json"); sourceConn.setRequestProperty("Authorization", "Basic " + API_KEY); sourceConn.setRequestMethod("POST"); sourceConn.setDoOutput(true); sourceConn.setDoInput(true); String payload = String.format("{\"value\":\"%s\"}", newValue); System.out.println(payload); OutputStream os = sourceConn.getOutputStream(); os.write(payload.getBytes()); os.flush(); os.close(); int sourceResponseCode = ((HttpURLConnection) sourceConn).getResponseCode(); Reader ir = sourceResponseCode == 200 ? new InputStreamReader(sourceConn.getInputStream()) : new InputStreamReader(sourceConn.getErrorStream()); BufferedReader in = new BufferedReader(ir); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); if (sourceResponseCode != 200) { throw new EslException(response.toString()); } } catch (Exception e) { throw new RuntimeException("Something went wrong when invoking API Call: POST " + url); } finally { if (sourceConn != null) { sourceConn.disconnect(); } } }And the attachment is the complete code I used for test. DuoReply to: Updating textField value when last signer signs the document.
Friday, August 9, 2019 at 11:14amReply to: Updating textField value when last signer signs the document.
Friday, August 9, 2019 at 11:20amReply to: Updating textField value when last signer signs the document.
Monday, August 12, 2019 at 04:59amReply to: Updating textField value when last signer signs the document.
Monday, August 12, 2019 at 05:02am