Philip

Custom Field - passing value to Template

0 votes
Hello, How do you populate a field when creating a package from a template? I don't want to define the field location in my code. Instead I need to simply pass along the value that should appear in the correct location. Some of these uses will be for read only fields and some for pre-populating an input that is required/optional. I've successfully setup a template using the online interface and placed a field with the name "CustomField1" inside the template. But I cannot find how to pass a field value unless I also upload a document and define the field location, which I do not want to do since that is already defined & maintained in the template. Thanks,

Approved Answer

Reply to: Custom Field - passing value to Template

0 votes
Hey Philip, Sorry for the delay. I had been waiting for you account issue to be resolved before posting in this thread anymore, then forgot to post the example. Take a look at this example from the code share to show how to push data to labels and text fields when using a template to create a package. https://developer.esignlive.com/code-share/push-data-fields-creating-package-template-net/ Let me know if you have questions.

- Michael

Director, Partner and Developer Technologies, OneSpan

Facebook - Twitter - LinkedIn


Reply to: Custom Field - passing value to Template

0 votes
Are you definitely wanting to use templates? If you create your documents as PDF forms, you could automatically extract fields from the PDF and inject text where you want it at package creation or document upload (if adding to an existing package) time. Let me know.

- Michael

Director, Partner and Developer Technologies, OneSpan

Facebook - Twitter - LinkedIn


Reply to: Custom Field - passing value to Template

1 votes
Thank you for responding Michael. Yes I was asking about using the template. If this feature does not exist we can probably achieve everything by using PDF form fields. I just wanted to make sure I knew how to implement that feature if it existed because sometimes its the only way to solve an issue without defining field locations in code and sometimes its just quicker/simpler solution.

Reply to: Custom Field - passing value to Template

0 votes
The only difference between a template vs creating the PDF form and uploading with code each time is that with a template, you don't have to re-upload the document each time. Instead, it duplicates the document inside eSignLive. Uploading the document each time probably won't cause too much more of a delay, but would probably be the simplest way to simply inject text into the fields you want to inject it into, without specifying a location. I'll work on a simple example of the template way for you though. I'll post it in the code share and add a link, in here.

- Michael

Director, Partner and Developer Technologies, OneSpan

Facebook - Twitter - LinkedIn


Reply to: Custom Field - passing value to Template

0 votes
Hi Michael, I'm trying to do something similar. So I have a PDF form with many input fields, if I use it to create a template, is it possible to inject values into it without uploading the PDF again? Based on the example provided with the Silanis SDK and what you said above, I'm under the impression that the only way to do this is to replace the original PDF with the values-injected version, so basically uploading a file again. In that case, there doesn't seem to be a lot of benefits from using a template. Is that correct?

Reply to: Custom Field - passing value to Template

0 votes
Thanks Michael, that last bit was what I was after. Field Field2 = mydoc.Signatures[0].Fields[0]; Field2.Value = "My editable value"; eslClient.ApprovalService.ModifyField(packageId, docId, sigId, Field1);

Reply to: Custom Field - passing value to Template

0 votes
Philip, glad I could help! :) yl-qtrade, Yes, this is correct. Templates were probably originally designed with the UI in mind, not from the API/SDK. From the API/SDK, your class essentially works as a template does. If you truly want to inject data into the document in PDF form fields that are in your original PDF, you'll need to do this at the time of upload. Hope this helps.

- Michael

Director, Partner and Developer Technologies, OneSpan

Facebook - Twitter - LinkedIn


Reply to: Custom Field - passing value to Template

0 votes
Hello, When i use your example, I am getting this message while trying to sign the document ("Warning, the form is incomplete")?? Why? What is wrong? Thanks

Reply to: Custom Field - passing value to Template

0 votes
Hello nehme, Are you using the code exactly from the example? Or have you modified the idea into your own example? Can you please share your code (with no API Key or personal info included)?

- Michael

Director, Partner and Developer Technologies, OneSpan

Facebook - Twitter - LinkedIn


Reply to: Custom Field - passing value to Template

0 votes
Hello, Thanks for your reply. The issue was simple, I just went for each field in the templates UI and click settings for it and click save. This solve my problem. Thanks :)

Reply to: Custom Field - passing value to Template

0 votes
Great! Glad you found your issue! Let us know whenever you have any other questions. :)

- Michael

Director, Partner and Developer Technologies, OneSpan

Facebook - Twitter - LinkedIn


Reply to: Custom Field - passing value to Template

0 votes
Hello, How I can get the Field index when I create it in template? Thanks

Reply to: Custom Field - passing value to Template

0 votes
This example was very simple. In a real scenario, you'd likely loop through the signatures and find the field by name rather than simply using static values.

- Michael

Director, Partner and Developer Technologies, OneSpan

Facebook - Twitter - LinkedIn


Reply to: Custom Field - passing value to Template

0 votes
Can you give me an .net sdk example about how to do this? Thanks

Reply to: Custom Field - passing value to Template

0 votes

How can i create a custom fields? the fields custom they are by package?


Reply to:

0 votes

Hi csar,

 

Thanks for your post! Custom Fields in OneSpan Sign offers you the ability to add supplementary information to your sender profiles in addition to the out-of-the-box fields like “title”, “company”. These custom fields can later be added to your transactions, and the values will be populated to the document after signing.You can only create custom fields for senders at the account level. To learn more about custom fields, refer to my blogs:
OneSpan Sign Developer – Custom Fields

OneSpan Sign Developer – Custom Fields Part 2

 

Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: Custom Field - passing value to Template

0 votes

Hi mwilliams

I'm new to OSS. This is exactly what I want - "...create your documents as PDF forms, you could automatically extract fields from the PDF and inject text where you want it at package creation or document upload (if adding to an existing package) time". But I don't know how to place the fields "full_name" and "amount" in the PDF using below code. I tried curly braces {full_name} and square brackets [full_name], but neither worked. Could you advise? Thanks!

            .withDocument(DocumentBuilder.newDocumentWithName("sampleAgreement")
                    .fromFile("sources/TestTemplate.pdf")
                    .enableExtraction()
                    .withInjectedField(FieldBuilder.textField()
                            .withName("amount")
                            .withValue("50000"))
                    .withInjectedField(FieldBuilder.textField()
                            .withName("full_name")
                            .withValue("John Doe"))

 

J.P.

Regards,

Jianping Xu (J.P.)

Bonterra (formerly, CyberGrants)


Reply to: Custom Field - passing value to Template

0 votes

Hi Jianping,

 

I've attached an example PDF, where you can directly name the field "amount" and "full_name" without the brackets:

        DocumentPackage packageToSend = PackageBuilder.newPackageNamed("Field Injection Example")
                .withSigner(SignerBuilder.newSignerWithEmail("[email protected]")
                        .withFirstName("John")
                        .withLastName("Smith")
                        .withCustomId("Signer1")
                )
                .withDocument(DocumentBuilder.newDocumentWithName("Sample Contract")
                        .fromFile(FILE_PATH)
                        .enableExtraction()
                        .withInjectedField(FieldBuilder.textField()
                                .withName("amount")
                                .withValue("50000"))
                        .withInjectedField(FieldBuilder.textField()
                                .withName("full_name")
                                .withValue("John Doe"))
                        .withSignature(SignatureBuilder.signatureFor("[email protected]")
                                     .atPosition(100, 100)
                                     .onPage(0)
                                     .withSize(150, 50))
                        )
                .build();
        
        PackageId packageId = eslClient.createPackageOneStep(packageToSend);

 

4-25-1

 

Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Attachments

Reply to: Custom Field - passing value to Template

0 votes

Thank you Duo for your quick answer! I used your PDF file in my test code and it worked too.

Unfortunately I don't have paid Adobe Acrobat to create/edit PDF files? We always create the template in HTML with placeholder fields, then covert it to a PDF file (programmatically, or manually load HTML to Word and then save as PDF). I tried to use the HTML <input> tag for the fields, and again it's not recognized by OSS. Do you know if there is HTML equivalent to the PDF form fields, or in other words how the PDF form field names can be defined in source HTML?

My simple HTML source for PDF looks like blow:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<form>
    <p>Name: <input name="full_name"></p>
    <p>Amount: <input name="amount"></p>
</form>
</body>
</html>

Regards,

Jianping Xu (J.P.)

Bonterra (formerly, CyberGrants)


Attachments

Reply to: Custom Field - passing value to Template

0 votes

Thanks Duo Liang! In my case, We'll populate our own custom fields (they are read-only anyway) before forming the PDF file and just do the signer related fields on the PDF.

Regards,

Jianping Xu (J.P.)

Bonterra (formerly, CyberGrants)


Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off